EDU.oswego.cs.dl.util.concurrent
public class ObservableSync extends Object implements Sync
Because ObservableSync does not itself perform any synchronization control, the attempt operation always succeeds. This class is typically used (via LayeredSync) as a wrapper around those that do perform synchronization control.
This class is based around a standard Observer design pattern. It is not hard to convert this to instead use a Listener design (as seen in AWT and JavaBeans), by defining associated EventObjects and forwarding them.
Nested Class Summary | |
---|---|
interface | ObservableSync.SyncObserver
Interface for objects that observe ObservableSyncs.
|
Field Summary | |
---|---|
protected Object | arg_ |
protected CopyOnWriteArraySet | observers_ |
Constructor Summary | |
---|---|
ObservableSync(Object notificationArgument)
Create an ObservableSync that uses the supplied argument
for all notifications. |
Method Summary | |
---|---|
void | acquire() |
void | attach(ObservableSync.SyncObserver obs) Add obs to the set of observers * |
boolean | attempt(long msecs) |
void | detach(ObservableSync.SyncObserver obs) Remove obs from the set of observers. |
Object | getNotificationArgument()
Return the argument used for notifications
|
Iterator | observers() Return an iterator that can be used to traverse through
current set of observers
|
void | release() |
Object | setNotificationArgument(Object notificationArg)
Set the argument used for notifications. |
Returns: the previous value of this argument