#include <ace/ACE_SV_Semaphore_Complex.h>
class ACE_SV_Semaphore_Complex : private ACE_SV_Semaphore_Simple {
public:
enum { ACE_CREATE = IPC_CREAT, ACE_OPEN = 0 };
ACE_SV_Semaphore_Complex (void);
ACE_SV_Semaphore_Complex ( key_t key, int create = ACE_SV_Semaphore_Complex::ACE_CREATE, int initial_value = 1, u_short nsems = 1, int perms = ACE_DEFAULT_FILE_PERMS );
ACE_SV_Semaphore_Complex ( const char *name, int create = ACE_SV_Semaphore_Complex::ACE_CREATE, int initial_value = 1, u_short nsems = 1, int perms = ACE_DEFAULT_FILE_PERMS );
~ACE_SV_Semaphore_Complex (void);
int open ( const char *name, int flags = ACE_SV_Semaphore_Simple::ACE_CREATE, int initial_value = 1, u_short nsems = 1, int perms = ACE_DEFAULT_FILE_PERMS );
int open ( key_t key, int flags = ACE_SV_Semaphore_Simple::ACE_CREATE, int initial_value = 1, u_short nsems = 1, int perms = ACE_DEFAULT_FILE_PERMS );
int close (void);
int acquire (u_short n = 0, int flags = 0) const;
int acquire_read (u_short n = 0, int flags = 0) const;
int acquire_write (u_short n = 0, int flags = 0) const;
int tryacquire (u_short n = 0, int flags = 0) const;
int tryacquire_read (u_short n = 0, int flags = 0) const;
int tryacquire_write (u_short n = 0, int flags = 0) const;
int release (u_short n = 0, int flags = 0) const;
int op (int val, u_short n = 0, int flags = 0) const;
int op (sembuf op_vec[], u_short n) const;
int control (int cmd, semun arg, u_short n = 0) const;
int control (int cmd, int value = 0, u_short n = 0) const;
ACE_USING ACE_SV_Semaphore_Simple::get_id;
ACE_USING ACE_SV_Semaphore_Simple::remove;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
private:
static const int BIGCOUNT_;
static sembuf op_lock_[2];
static sembuf op_endcreate_[2];
static sembuf op_open_[1];
static sembuf op_close_[3];
static sembuf op_unlock_[1];
};
The second member, [1], of the ACE_SV_Semaphore is used as a lock variable to avoid any race conditions in the create() and close() functions.
The members beyond [1] are actual ACE_SV_Semaphore values in the array of SV_Semaphores (which may be sized by the user in the constructor).
ACE_SV_Semaphore_Complex (void);
ACE_SV_Semaphore_Complex (
key_t key,
int create = ACE_SV_Semaphore_Complex::ACE_CREATE,
int initial_value = 1,
u_short nsems = 1,
int perms = ACE_DEFAULT_FILE_PERMS
);
ACE_SV_Semaphore_Complex (
const char *name,
int create = ACE_SV_Semaphore_Complex::ACE_CREATE,
int initial_value = 1,
u_short nsems = 1,
int perms = ACE_DEFAULT_FILE_PERMS
);
~ACE_SV_Semaphore_Complex (void);
int open (
const char *name,
int flags = ACE_SV_Semaphore_Simple::ACE_CREATE,
int initial_value = 1,
u_short nsems = 1,
int perms = ACE_DEFAULT_FILE_PERMS
);
int open (
key_t key,
int flags = ACE_SV_Semaphore_Simple::ACE_CREATE,
int initial_value = 1,
u_short nsems = 1,
int perms = ACE_DEFAULT_FILE_PERMS
);
int close (void);
remove
method, this
method is for a process to call before it exits, when it is done
with the ACE_SV_Semaphore. We "decrement" the counter of
processes using the ACE_SV_Semaphore, and if this was the last
one, we can remove the ACE_SV_Semaphore.
int acquire (u_short n = 0, int flags = 0) const;
int acquire_read (u_short n = 0, int flags = 0) const;
int acquire_write (u_short n = 0, int flags = 0) const;
int tryacquire (u_short n = 0, int flags = 0) const;
int tryacquire_read (u_short n = 0, int flags = 0) const;
int tryacquire_write (u_short n = 0, int flags = 0) const;
int release (u_short n = 0, int flags = 0) const;
int op (int val, u_short n = 0, int flags = 0) const;
int op (sembuf op_vec[], u_short n) const;
int control (int cmd, semun arg, u_short n = 0) const;
int control (int cmd, int value = 0, u_short n = 0) const;
ACE_USING ACE_SV_Semaphore_Simple::get_id;
ACE_USING ACE_SV_Semaphore_Simple::remove;
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;