/usr/include/falcon/baton.h is in falconpl-dev 0.9.6.9-git20120606-2.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | /*
FALCON - The Falcon Programming Language.
FILE: baton.h
Baton synchronization structure.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: Sat, 14 Mar 2009 00:03:28 +0100
-------------------------------------------------------------------
(C) Copyright 2004: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
#ifndef FLC_BATON_H
#define FLC_BATON_H
#include <falcon/setup.h>
#include <falcon/basealloc.h>
namespace Falcon {
/** 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).
*/
class FALCON_DYN_CLASS Baton: public BaseAlloc
{
void *m_data;
public:
Baton( bool bBusy = false );
virtual ~Baton();
/** 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.
*/
virtual void acquire();
/** 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.
\return true if the baton is acquired.
*/
bool tryAcquire();
/** Releases the baton.
This makes the baton available for another acquirer.
*/
virtual void release();
/** 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.
*/
void checkBlock();
/** 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.
\return true on success.
*/
bool block();
/** 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.
\return true if the thread was owning the block onthe baton.
*/
bool unblock();
/** Debug routine.
True if currently busy.
*/
bool busy();
/** Function called when the baton is released while there is a pending blocking request.
The base class version does nothing.
*/
virtual void onBlockedAcquire();
};
}
#endif
/* end of baton.h */
|