Falcon::Baton Class Reference

Baton concurrency controller class. More...

#include <baton.h>

Inheritance diagram for Falcon::Baton:

Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void acquire ()
 Acquires the baton.
 Baton (bool bBusy=false)
bool block ()
 Blocks the baton.
bool busy ()
 Debug routine.
void checkBlock ()
 Checks if the baton is blocked, honouring pending block requests.
virtual void onBlockedAcquire ()
 Function called when the baton is released while there is a pending blocking request.
virtual void release ()
 Releases the baton.
bool tryAcquire ()
 Tries to acquire the baton.
bool unblock ()
 Unblocks the baton.
virtual ~Baton ()


Detailed Description

Baton concurrency controller class.

Like in a 4x4 relay match, a baton is an object which gives the grant to continue operating on a set of objects. It is tightly related with the concept of "monitor", but other than that, it is possible to force blockade of the runner by issuing a block request.

It is used by VM users and by the GC, which has inspection rights that overseed VM execution rights (normally).


Constructor & Destructor Documentation

Falcon::Baton::Baton ( bool  bBusy = false  ) 

virtual Falcon::Baton::~Baton (  )  [virtual]


Member Function Documentation

virtual void Falcon::Baton::acquire (  )  [virtual]

Acquires the baton.

The caller blocks until it is able to acquire the baton. If the baton is blocked, it can be acquired only by the blocking thread.

Note:
Succesful acquisition of the blocking thread causes the baton to be automatically unblocked.

Referenced by Falcon::VMachine::unidle().

bool Falcon::Baton::block (  ) 

Blocks the baton.

If the call is succesful, this prevents any acquire request coming from other threads to be accepted.

Only one thread can block the baton; the call will fail if there is an already pending block request issued by another thread. It will succed (with no effect) if the caller thread is the one already blocking the baton.

Returns:
true on success.

bool Falcon::Baton::busy (  ) 

Debug routine.

True if currently busy.

void Falcon::Baton::checkBlock (  ) 

Checks if the baton is blocked, honouring pending block requests.

If the baton is blocked, it is atomically released and the calling thread puts itself in wait for re-acquisition.

virtual void Falcon::Baton::onBlockedAcquire (  )  [virtual]

Function called when the baton is released while there is a pending blocking request.

The base class version does nothing.

Reimplemented in Falcon::VMBaton.

virtual void Falcon::Baton::release (  )  [virtual]

Releases the baton.

This makes the baton available for another acquirer.

Reimplemented in Falcon::VMBaton.

bool Falcon::Baton::tryAcquire (  ) 

Tries to acquire the baton.

If the baton is currently available (unacquired) it is acquired, unless blocked. If it is blocked, it can be acquired only by the blocker thread.

Note:
Succesful acquisition of the blocking thread causes the baton to be automatically unblocked.
Returns:
true if the baton is acquired.

bool Falcon::Baton::unblock (  ) 

Unblocks the baton.

If a succesful blocking thread decides it doesn't want to acquire the baton anymore, it can cast an unblock() to allow other acquiring threads to progress.

Note:
A succesful acquisition releases atomically the block request.
Returns:
true if the thread was owning the block onthe baton.


The documentation for this class was generated from the following file:

Generated on Mon Oct 19 10:11:32 2009 for Falcon_Core by  doxygen 1.5.8