#include <ace/Synch.h>
class ACE_Semaphore {
public:
ACE_Semaphore ( u_int count = 1, int type = USYNC_THREAD, LPCTSTR name = 0, void * = 0, int max = 0x7fffffff );
~ACE_Semaphore (void);
int remove (void);
int acquire (void);
int acquire (ACE_Time_Value &tv);
int tryacquire (void);
int release (void);
int release (size_t release_count);
int acquire_read (void);
int acquire_write (void);
int tryacquire_read (void);
int tryacquire_write (void);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
const ACE_sema_t &lock (void) const;
protected:
ACE_sema_t semaphore_;
int removed_;
private:
void operator= (const ACE_Semaphore &);
ACE_Semaphore (const ACE_Semaphore &);
};
ACE_Semaphore (
u_int count = 1,
int type = USYNC_THREAD,
LPCTSTR name = 0,
void * = 0,
int max = 0x7fffffff
);
~ACE_Semaphore (void);
int remove (void);
int acquire (void);
int acquire (ACE_Time_Value &tv);
tv
times out or until the semaphore
count becomes greater than 0 (at which point it is decremented).
Note that tv
is assumed to be in "absolute" rather than
"relative" time. The value of tv
is updated upon return to
show the actual (absolute) acquisition time.
NOTE: Solaris threads do not support timed semaphores. Therefore, if you're running on Solaris you might want to consider using the ACE POSIX pthreads implementation instead, which can be enabled by compiling ACE with -D_POSIX_PTHREAD_SEMANTICS.
int tryacquire (void);
errno
is set to
EBUSY
.
int release (void);
int release (size_t release_count);
release_count
, potentially
unblocking waiting threads.
int acquire_read (void);
acquire
and is only
here to make the ACE_Semaphore
interface consistent with the
other synchronization APIs.
int acquire_write (void);
acquire
and is only
here to make the ACE_Semaphore
interface consistent with the
other synchronization APIs.
int tryacquire_read (void);
tryacquire
and is only here to make the ACE_Semaphore
interface consistent with the other synchronization APIs.
Returns -1 on failure. If we "failed" because someone else
already had the lock, errno
is set to EBUSY
.
int tryacquire_write (void);
tryacquire
and is only here to make the ACE_Semaphore
interface consistent with the other synchronization APIs.
Returns -1 on failure. If we "failed" because someone else
already had the lock, errno
is set to EBUSY
.
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
const ACE_sema_t &lock (void) const;
void operator= (const ACE_Semaphore &);
ACE_Semaphore (const ACE_Semaphore &);