|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpt.ua.concurrent.CObject
pt.ua.concurrent.Event
public class Event
A simple module supporting two valued events.
An event is a double-valued variable (0
and 1
),
in which a client may wait for one of this two states.
This class follows DbC(tm) methodology
(Wikipedia).
Where possible, contracts are implement with native's Java
assert.
Constructor Summary | |
---|---|
Event(boolean initial)
Creates an event with initial state and registering waiting threads. |
|
Event(boolean initial,
boolean registerAwaitingThreads)
Creates an event with initial state. |
Method Summary | |
---|---|
void |
await(boolean state)
Wait for a given state value. |
void |
reset()
Reset the event state (false). |
void |
set()
Set the event state (true). |
boolean |
stateMatches(boolean state)
Does current state matches argument? This method should be used with utmost care, because its result, depending on the event's usage, might change immediately after it has been called (race condition). |
void |
toggle()
Toggle the event state. |
Methods inherited from class pt.ua.concurrent.CObject |
---|
await, await, await, broadcast, interruptWaitingThreads, lockIsMine, registerAwaitingThreads, signal, syncronizedLockIsMine |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Event(boolean initial)
initial
- state valuepublic Event(boolean initial, boolean registerAwaitingThreads)
registerAwaitingThreads
- if true, threads are registered when waitingMethod Detail |
---|
public void set()
public void reset()
public void toggle()
public boolean stateMatches(boolean state)
public void await(boolean state) throws ThreadInterruptedException
state
- value to wait for
ThreadInterruptedException
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |