com.softsynth.jsyn
Class SharedSleeper

java.lang.Object
  extended by com.softsynth.jsyn.SharedSleeper

public class SharedSleeper
extends java.lang.Object

Allow multiple threads to sleep on a single resource such as a non-real-time software synthesizer.

Author:
(C) 2000 Phil Burk, SoftSynth.com, All Rights Reserved

Constructor Summary
SharedSleeper()
           
 
Method Summary
 void addThread()
          Add current thread to list of Threads that share this sleeper.
 void addThread(java.lang.Thread thread)
          Add thread to list of Threads that share this sleeper.
 int bumpIndex()
          Overridden by clients to perform work.
 int getIndex()
           
 void removeThread()
           
 void setIndex(int index)
           
 int sleepUntilIndex(int desiredIndex)
          Sleep until the given index is reached.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedSleeper

public SharedSleeper()
Method Detail

addThread

public void addThread(java.lang.Thread thread)
Add thread to list of Threads that share this sleeper. Adding a thread can prevent the other threads from advancing and leaving this one behind. If a thread has already been added, nothing happens.


addThread

public void addThread()
Add current thread to list of Threads that share this sleeper.


removeThread

public void removeThread()

setIndex

public void setIndex(int index)

getIndex

public int getIndex()

bumpIndex

public int bumpIndex()
Overridden by clients to perform work.


sleepUntilIndex

public int sleepUntilIndex(int desiredIndex)
                    throws java.lang.InterruptedException
Sleep until the given index is reached. Index can wrap around as long as we don't wait for more than half a circle.

Throws:
java.lang.InterruptedException