---
name: "corelinux_AbstractSemaphore"
section: "3"
platform: "linux"
package: "libcorelinux-dev"
version: "0.4.32-5"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/corelinux_AbstractSemaphore"
---

# corelinux\_AbstractSemaphore(3)

A AbstractSemaphore supports the protocol that processes and/or threads agree to follow for the purpose of controlled access to a resource.

## NAME

corelinux::AbstractSemaphore - A **AbstractSemaphore** supports the protocol that processes and/or threads agree to follow for the purpose of controlled access to a resource.

## SYNOPSIS

`#include <AbstractSemaphore.hpp>`

Inherits **corelinux::Synchronized**.

Inherited by **corelinux::Semaphore**.

### Public Member Functions

**AbstractSemaphore** (**SemaphoreGroupPtr**, **SemaphoreIdentifierRef**)  throw ( NullPointerException )\
 *Default constructor.*  virtual **~AbstractSemaphore** (void)\
 *Virtual Destructor.*  bool **operator==** (**AbstractSemaphoreCref** aRef) const \
 *Equality operator returns true if identifiers match.*  virtual bool **isBalkingEnabled** (void) const =0\
 *Returns true if balking enabled.*  virtual bool **isRecursionEnabled** (void) const =0\
 *Returns true if recursion allowed.*  **SemaphoreIdentifierCref** **getIdentifier** (void) const \
 *Return a reference to this* **AbstractSemaphore** *identifier.*  **SemaphoreGroupIdentifierCref** **getGroupIdentifier** (void) const \
 *Returns a reference to the* **SemaphoreGroup** *identifier.*  virtual ThreadIdentifierCref **getOwningThreadIdentifier** (void) const =0\
 *Returns the identifier of who currently owns the semaphore.*  virtual CounterCref **getRecursionQueueLength** (void) const =0\
 *Return the depth of the recursion for the owner.*  Int **getValue** (void)\
 *Returns the current value of the semaphore.*  Int **getInitialValue** (void)\
 *Retrieves the initial value for a semaphore.*  virtual bool **isLocked** (void)=0\
 *Ask if* **AbstractSemaphore** *instance is locked.*  virtual **SemaphoreOperationStatus** **lockWithWait** (void)=0  throw (SemaphoreException)\
 **Request** *the lock, wait for availability.*  virtual **SemaphoreOperationStatus** **lockWithNoWait** (void)=0  throw (SemaphoreException)\
 **Request** *the lock without waiting.*  virtual **SemaphoreOperationStatus** **release** (void)=0  throw (SemaphoreException)\
 *Release the lock.*

### Protected Member Functions

**AbstractSemaphore** (**AbstractSemaphoreCref**)  throw (Assertion)\
 **AbstractSemaphoreRef** **operator=** (**AbstractSemaphoreCref**)  throw (Assertion)\
 **SemaphoreIdentifierRef** **getId** (void)\
 *Returns a reference to the* **AbstractSemaphore** *identifier.*  Int **getGroupId** (void) const \
 *Returns a reference to the group identifier.*  virtual ThreadIdentifierRef **getOwnerId** (void)=0\
 *Returns a reference to the owning thread.*  **SemaphoreOperationStatus** **setLock** (Int)\
 *Calls kernel lock mechanism.*  **SemaphoreOperationStatus** **setUnlock** (Int)\
 *Calls kernel unlock mechanism.*  **SemaphoreOperationStatus** **waitZero** (Int)\
 *Calls kernel zero mechanism.*  **SemaphoreOperationStatus** **setValue** (Int)\
 *Sets the value for the* **AbstractSemaphore***.*

## Detailed Description

A **AbstractSemaphore** supports the protocol that processes and/or threads agree to follow for the purpose of controlled access to a resource.

The resource can be anything that the developer considers to need access controls on such as memory, hardware, methods, computer instructions, and so on.

Callers can elect to avoid being put into a blocked state and return immediately without control to the resource. Callers may also request that they are put into a blocked state for a specified amount of time. If, at the end of the specified time, the request has not been satisfied, it is returned with a Timeout indicator.

The owner or creator of the **AbstractSemaphore** can elect to enforce balking behavior on a **AbstractSemaphore**. When so designated, the **AbstractSemaphore** can turn back any request until some condition in their solution space is met regardless of the callers blocking options. If a caller access attempt is balked, is it returned with a Balked indicator.

## Author

Generated automatically by Doxygen for CoreLinux++ from the source code.
