---
name: "corelinux_GatewaySemaphore"
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_GatewaySemaphore"
---

# corelinux\_GatewaySemaphore(3)

GatewaySemphore enables a depth of resource indicator.

## NAME

corelinux::GatewaySemaphore - GatewaySemphore enables a depth of resource indicator.

## SYNOPSIS

`#include <GatewaySemaphore.hpp>`

Inherits **corelinux::Semaphore**.

### Public Member Functions

**GatewaySemaphore** (**SemaphoreGroupPtr**, **SemaphoreIdentifierRef**, Count, bool Recursive=false, bool Balking=false)  throw ( NullPointerException )\
 *Default constructor requires the identifier of the semaphore in the semaphore group and a count of resources for control.*  virtual **~GatewaySemaphore** (void)\
 *Virtual Destructor.*  virtual bool **isLocked** (void)\
 *Ask if* **AbstractSemaphore** *instance is locked.*  virtual bool **isAnOwner** (void)\
 *Returns true if calling thread owns a resource.*  virtual Counter **getOwnerRecursionQueueLength** (void)\
 *Returns the recursion depth for the calling thread.*  virtual **SemaphoreOperationStatus** **lockWithWait** (void)  throw ( SemaphoreException )\
 **Request** *the lock, wait for availability.*  virtual **SemaphoreOperationStatus** **lockWithNoWait** (void)  throw ( SemaphoreException )\
 **Request** *the lock without waiting.*  virtual **SemaphoreOperationStatus** **release** (void)  throw ( SemaphoreException )\
 *Release the lock.*

### Protected Member Functions

**GatewaySemaphore** (void)  throw ( Assertion )\
 *Default construct throws assert.*  **GatewaySemaphore** (**GatewaySemaphoreCref**)  throw ( Assertion )\
 *Copy constructor throws assertion.*  **GatewaySemaphoreRef** **operator=** (**GatewaySemaphoreCref**)  throw ( Assertion )\
 *Assignment operator throws assertion.*  **SemaphoreOperationStatus** **lockAndAdd** (ThreadIdentifierRef aTid, Int aFlag=0)\

## Detailed Description

GatewaySemphore enables a depth of resource indicator.

Unlike the tradition boolean semaphore (locked,unlocked), this type assumes a finite number of threads/processes can be granted access up to theResourceMaximum. The semantics regarding semaphore and recursion in relationship to the **GatewaySemaphore** is as follows:

With recursion enabled:

- •

  **Semaphore::getOwningThreadIdentifier returns the ThreadIdentifier of the thread that pushed the value to zero(0).**

- •

  **Semaphore::getRecursionQueueLength returns the depth of recursion by Semaphore::getOwningThreadIdentifier**

- •

  **GatewaySemaphore::isAnOwner returns true if the current thread is in the set of threads that own a resource.**

- •

  **GatewaySemaphore::getOwnerRecursionQueueLength returns either -1 if the current thread does not control a resource, 0 if the current thread does own a resource, but has not recursed, or returns the depth of recursion for the calling thread.**

## Constructor & Destructor Documentation

### corelinux::GatewaySemaphore::GatewaySemaphore (SemaphoreGroupPtr, SemaphoreIdentifierRef, Count, bool Recursive = false, bool Balking = false) throw ( NullPointerException )

**Default constructor requires the identifier of the semaphore in the semaphore group and a count of resources for control. Parameters:**

*SemaphoreGroupPtr* **The owning SemaphoreGroup** \
 *SemaphoreIdentifier* **The identifier for the Semaphore from the SemaphoreGroup** \
 *Count* **number of resources the semaphore controls** \
 *bool* **true if recursion enabled** \
 *bool* **true if balking enabled**

## Member Function Documentation

### Counter corelinux::GatewaySemaphore::getOwnerRecursionQueueLength (void)` [virtual]`

**Returns the recursion depth for the calling thread. Returns:**

**Counter -1 if not an owner, 0 if owner but not recursed, or \> 0 for recursion depth.**

## Author

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