org.curjent.impl.agent
Interface Awaiter

All Known Implementing Classes:
CopyMessage_Copy, CopyMessage_Count, CopyMessage_Exists, CopyMessage_File, CopyMessage_Flush, CopyMessage_Length, CopyMessage_Read, CopyMessage_Status, Message, SyntheticMessage

interface Awaiter

Interface for await logic implemented by Awaiters.

Awaiters are both locked and synchronized before waiting. The awaiter is locked first via lock() and then the awaiter monitor is acquired via a synchronized block on the awaiter instance. Implementation of lock() is optional, but the await logic always synchronizes on the awaiter object.

See Also:
Awaiters.await(Awaiter, boolean, CallState, long)

Method Summary
 void await(long nanos)
          Called within the locked and synchronized await block to suspend the current thread until notified or the given timeout value has expired.
 void clearDeadcheckRequest()
          Sets the logical "deadcheck requested" flag to false.
 void deadcheck()
          Signals awaiting threads to check for deadlock.
 Thread[] getBlockingThreads()
          Used by the controller and by Deadlocks to keep track of which agents are blocking which threads.
 Controller getController()
          Returns the controller instance of the awaiter.
 boolean isDeadcheckRequested()
          Returns true if this thread has an outstanding deadcheck request.
 boolean isExecuting()
          Returns true if the awaiter is a Message and it is in the EXECUTING state.
 boolean isSatisfied(CallState state)
          Returns true if the await condition has been satisfied.
 void lock()
          Optionally acquires the controller's lock.
 void unlock()
          Optionally releases the controller's lock.
 

Method Detail

getController

Controller getController()
Returns the controller instance of the awaiter.


lock

void lock()
Optionally acquires the controller's lock.


unlock

void unlock()
Optionally releases the controller's lock.


isExecuting

boolean isExecuting()
Returns true if the awaiter is a Message and it is in the EXECUTING state. Synchronous calls simulate direct method invocations and are not candidates for deadlock notification once they begin executing (another non-executing or non-synchronous call is chosen instead).


isSatisfied

boolean isSatisfied(CallState state)
Returns true if the await condition has been satisfied. This awaiter may or may not utilize the optional state value passed to Awaiters.await(Awaiter, boolean, CallState, long) and forwarded to this method.


await

void await(long nanos)
           throws InterruptedException
Called within the locked and synchronized await block to suspend the current thread until notified or the given timeout value has expired.

Throws:
InterruptedException

deadcheck

void deadcheck()
Signals awaiting threads to check for deadlock. Logically sets the "deadcheck requested" flag to true.


isDeadcheckRequested

boolean isDeadcheckRequested()
Returns true if this thread has an outstanding deadcheck request. If it does, the await loop checks for deadlock before awaiting again.


clearDeadcheckRequest

void clearDeadcheckRequest()
Sets the logical "deadcheck requested" flag to false.


getBlockingThreads

Thread[] getBlockingThreads()
Used by the controller and by Deadlocks to keep track of which agents are blocking which threads. This accounting is used during deadlock detection to determine thread block dependencies and possible circular deadlocked dependencies.



Copyright 2009-2011 Tom Landon
Apache License 2.0