#include <baton.h>
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 () |
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).
Falcon::Baton::Baton | ( | bool | bBusy = false |
) |
virtual Falcon::Baton::~Baton | ( | ) | [virtual] |
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.
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.
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.
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.