Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# ACE_SV_Semaphore_Simple Class Reference

This is a simple semaphore package that assumes there are no race conditions for initialization (i.e., the order of process startup must be well defined). More...

`#include <SV_Semaphore_Simple.h>`

Inheritance diagram for ACE_SV_Semaphore_Simple:

[legend]
List of all members.

## Public Types
enum | { ACE_CREATE = IPC_CREAT, ACE_EXCL = IPC_EXCL, ACE_OPEN = 0 }
## Public Methods
| ACE_SV_Semaphore_Simple (void)
| ACE_SV_Semaphore_Simple (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)
| ACE_SV_Semaphore_Simple (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)
| ~ACE_SV_Semaphore_Simple (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)
| Open or create one or more SV_Semaphores. We return 0 if all is OK, else -1. More...
int | close (void)
| Close a ACE_SV_Semaphore, marking it as invalid for subsequent operations... More...
int | remove (void) const
int | acquire (u_short n=0, int flags=0) const
int | acquire_read (u_short n=0, int flags=0) const
| Acquire a semaphore for reading. More...
int | acquire_write (u_short n=0, int flags=0) const
| Acquire a semaphore for writing. More...
int | tryacquire (u_short n=0, int flags=0) const
| Non-blocking version of <acquire>. More...
int | tryacquire_read (u_short n=0, int flags=0) const
| Try to acquire the semaphore for reading. More...
int | tryacquire_write (u_short n=0, int flags=0) const
| Try to acquire the semaphore for writing. More...
int | release (u_short n=0, int flags=0) const
| Increment ACE_SV_Semaphore by one. Dijkstra's V operation, Tannenbaums UP operation. More...
int | op (int val, u_short semnum=0, int flags=SEM_UNDO) const
| General ACE_SV_Semaphore operation. Increment or decrement by a specific amount (positive or negative; amount can`t be zero). More...
int | op (sembuf op_vec[], u_short nsems) const
| General ACE_SV_Semaphore operation on an array of SV_Semaphores. More...
int | control (int cmd, semun arg, u_short n=0) const
int | control (int cmd, int value=0, u_short n=0) const
int | get_id (void) const
| Get underlying internal id. More...
void | dump (void) const
| Dump the state of an object. More...
## Public Attributes
| ACE_ALLOC_HOOK_DECLARE
| Declare the dynamic allocation hooks. More...
## Protected Methods
int | init (key_t k=ACE_static_cast(key_t, ACE_INVALID_SEM_KEY), int i=-1)
key_t | name_2_key (const char *name)
## Protected Attributes
key_t | key_
| Semaphore key. More...
int | internal_id_
| Internal ID to identify the semaphore group within this process. More...
int | sem_number_
| Number of semaphores we're creating. More...

## Detailed Description

This is a simple semaphore package that assumes there are no race conditions for initialization (i.e., the order of process startup must be well defined).

## Member Enumeration Documentation

anonymous enum

  | Enumeration values:
  ACE_CREATE |
  ACE_EXCL |
  ACE_OPEN |

## Constructor & Destructor Documentation

ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple | ( | void |  | ) |

ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple | ( | key_t | k,
|  | int | flags = ACE_SV_Semaphore_Simple::ACE_CREATE,
|  | int | initial_value = 1,
|  | u_short | n = 1,
|  | int | perms = ACE_DEFAULT_FILE_PERMS
| ) |

ACE_SV_Semaphore_Simple::ACE_SV_Semaphore_Simple | ( | const char * | name,
|  | int | flags = ACE_SV_Semaphore_Simple::ACE_CREATE,
|  | int | initial_value = 1,
|  | u_short | n = 1,
|  | int | perms = ACE_DEFAULT_FILE_PERMS
| ) |

ACE_SV_Semaphore_Simple::~ACE_SV_Semaphore_Simple | ( | void |  | ) |

## Member Function Documentation

ASYS_INLINE int ACE_SV_Semaphore_Simple::acquire | ( | u_short | n = 0,
|  | int | flags = 0
| ) | const

| Wait until a ACE_SV_Semaphore's value is greater than 0, the decrement it by 1 and return. Dijkstra's P operation, Tannenbaums DOWN operation. Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::acquire_read | ( | u_short | n = 0,
|  | int | flags = 0
| ) | const

| Acquire a semaphore for reading. Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::acquire_write | ( | u_short | n = 0,
|  | int | flags = 0
| ) | const

| Acquire a semaphore for writing. Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::close | ( | void |  | ) |

| Close a ACE_SV_Semaphore, marking it as invalid for subsequent operations... Reimplemented in ACE_SV_Semaphore_Complex.

int ACE_SV_Semaphore_Simple::control | ( | int | cmd,
|  | int | value = 0,
|  | u_short | n = 0
| ) | const

| Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::control | ( | int | cmd,
|  | semun | arg,
|  | u_short | n = 0
| ) | const

| Reimplemented in ACE_SV_Semaphore_Complex.

void ACE_SV_Semaphore_Simple::dump | ( | void |  | ) | const

| Dump the state of an object. Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::get_id | ( | void |  | ) | const

| Get underlying internal id.

int ACE_SV_Semaphore_Simple::init | ( | key_t | k = ACE_static_cast (key_t, ACE_INVALID_SEM_KEY),
|  | int | i = -1
| ) | `[protected]`

| Convert name to key This function is used internally to create keys for the semaphores. A valid name contains letters and digits only and MUST start with a letter. The method for generating names is not very sophisticated, so caller should not pass strings which match each other for the first LUSED characters when he wants to get a different key.

key_t ACE_SV_Semaphore_Simple::name_2_key | ( | const char * | name | ) | `[protected]`

ASYS_INLINE int ACE_SV_Semaphore_Simple::op | ( | sembuf | op_vec[],
|  | u_short | n
| ) | const

| General ACE_SV_Semaphore operation on an array of SV_Semaphores. Reimplemented in ACE_SV_Semaphore_Complex.

int ACE_SV_Semaphore_Simple::op | ( | int | val,
|  | u_short | n = 0,
|  | int | flags = SEM_UNDO
| ) | const

| General ACE_SV_Semaphore operation. Increment or decrement by a specific amount (positive or negative; amount can`t be zero). Reimplemented in ACE_SV_Semaphore_Complex.

int ACE_SV_Semaphore_Simple::open | ( | key_t | k,
|  | int | create = ACE_SV_Semaphore_Simple::ACE_CREATE,
|  | int | initial_value = 1,
|  | u_short | nsems = 1,
|  | int | perms = ACE_DEFAULT_FILE_PERMS
| ) |

| Open or create one or more SV_Semaphores. We return 0 if all is OK, else -1. Reimplemented in ACE_SV_Semaphore_Complex.

int ACE_SV_Semaphore_Simple::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
| ) |

| Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::release | ( | u_short | n = 0,
|  | int | flags = 0
| ) | const

| Increment ACE_SV_Semaphore by one. Dijkstra's V operation, Tannenbaums UP operation. Reimplemented in ACE_SV_Semaphore_Complex.

int ACE_SV_Semaphore_Simple::remove | ( | void |  | ) | const

| Remove all SV_Semaphores associated with a particular key. This call is intended to be called from a server, for example, when it is being shut down, as we do an IPC_RMID on the ACE_SV_Semaphore, regardless of whether other processes may be using it or not. Most other processes should use <close> below.

ASYS_INLINE int ACE_SV_Semaphore_Simple::tryacquire | ( | u_short | n = 0,
|  | int | flags = 0
| ) | const

| Non-blocking version of <acquire>. Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::tryacquire_read | ( | u_short | n = 0,
|  | int | flags = 0
| ) | const

| Try to acquire the semaphore for reading. Reimplemented in ACE_SV_Semaphore_Complex.

ASYS_INLINE int ACE_SV_Semaphore_Simple::tryacquire_write | ( | u_short | n = 0,
|  | int | flags = 0
| ) | const

| Try to acquire the semaphore for writing. Reimplemented in ACE_SV_Semaphore_Complex.

## Member Data Documentation

ACE_SV_Semaphore_Simple::ACE_ALLOC_HOOK_DECLARE

| Declare the dynamic allocation hooks. Reimplemented in ACE_SV_Semaphore_Complex.

int ACE_SV_Semaphore_Simple::internal_id_`[protected]`

| Internal ID to identify the semaphore group within this process.

key_t ACE_SV_Semaphore_Simple::key_`[protected]`

| Semaphore key.

int ACE_SV_Semaphore_Simple::sem_number_`[protected]`

| Number of semaphores we're creating.

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

- SV_Semaphore_Simple.h
- SV_Semaphore_Simple.cpp
- SV_Semaphore_Simple.i