Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
None.
Inherited By:
TGlobalCountingSemaphoreHandle
TLocalCountingSemaphore
Purpose:
WARNING: Do not directly #include CountingSemaphore.h in any of your files. It is included in this version of the CommonPoint application system for internal implementation. It will be removed in future versions (and the public classes it contains will be moved to other public headers).
This class provides the abstract base for classical counting semaphores.
Instantiation:
This class is an abstract base class hence creation not allowed.
Deriving Classes:
Concurrency:
Multithread safe.
Resource Use:
No special requirements.
Other Considerations:
Derived classes are supposed to provide the actual implementation.
TCountingSemaphore (long count =0)
Interface Category:
API.
Purpose:
Constructor constructs the semaphore.
Calling Context:
Called by the derived class constructors only.
Parameters:
- long count =0 -initial count on the semaphore.
Return Value:
None.
Exceptions:
Throws TGeneralKernelException(TGeneralKernelException::kBadArgument) if count is less than zero.
Concurrency:
Multithread safe.
Other Considerations:
After construction the count of the semaphore is set to value of 'count'.
This constructor can only be invoked by the derived class constructors.
virtual ~ TCountingSemaphore ()
Interface Category:
API.
Purpose:
Destructor.
Calling Context:
Called to destroy an object.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Multithread safe.
Other Considerations:
- virtual void P ()
- virtual void P (const TTime & aTimeOut)
Interface Category:
API.
Purpose:
- Tries to decrement the count on the semaphore, waits if count is zero.
- Tries to decrement the count on the semaphore, waits for specified time if count is zero. Upon timeout throws an exception TTimeOutException::kTimeExpired.
Calling Context:
- Called to receive a signal or decrement the count.
- Called to receive a signal or decrement the count within certain time bound.
Parameters:
- Takes no parameters.
- const TTime & aTimeOut -the timeout value.
Return Value:
None.
Exceptions:
Throws TSemaphoreException(TSemaphoreException::kSemaphoreDeleted) if semaphore is being deleted.
Throws TSemaphoreException(TTimeOutException::kTimeExpired) if operation times out.
Concurrency:
Multithread safe.
Other Considerations:
- void Decrement ()
- void Decrement (const TTime & aTimeOut)
Interface Category:
API.
Purpose:
- Name alias to operation P.
- XName alias to operation P with timeout.
Calling Context:
- Called to receive a signal or decrement the count.
- Called to receive a signal or decrement the count within certain time bound.
Parameters:
- Takes no parameters.
- const TTime & aTimeOut -the timeout value.
Return Value:
None.
Exceptions:
Throws TSemaphoreException(TSemaphoreException::kSemaphoreDeleted) if semaphore is being deleted.
Throws TTimeOutException(TTimeOutException::kTimeExpired) if operation times out.
Concurrency:
Multithread safe.
Other Considerations:
virtual bool TryP ()
Interface Category:
API.
Purpose:
Tries to receive a signal or decrement the count, but doesn't wait if the count is zero.
Calling Context:
Called to receive a signal or decrement the count, without having to wait.
Parameters:
Return Value:
Returns true if successfully decremented the count, false otherwise.
Exceptions:
Throws TSemaphoreException(TSemaphoreException::kSemaphoreDeleted) if semaphore is being deleted.
Concurrency:
Multithread safe.
Other Considerations:
bool TryDecrement ()
Interface Category:
API.
Purpose:
Name alias to TryP.
Calling Context:
Tries to receive a signal or decrement the count, but doesn't wait if the count is zero.
Parameters:
Return Value:
Returns true if successfully decremented the count, false otherwise.
Exceptions:
Throws TSemaphoreException(TSemaphoreException::kSemaphoreDeleted) if semaphore is being deleted.
Concurrency:
Multithread safe.
Other Considerations:
virtual void V ()
Interface Category:
API.
Purpose:
Provides an operation to send a signal or to increment the count.
Calling Context:
Called to send a signal or to increment the count.
Parameters:
Return Value:
None.
Exceptions:
Throws TSemaphoreException(TSemaphoreException::kSemaphoreDeleted) if semaphore is being deleted.
Concurrency:
Multithread safe.
Other Considerations:
Any waiting threads are woken up in FIFO order.
void Increment ()
Interface Category:
API.
Purpose:
Name alias to operation V.
Calling Context:
Called to send a signal or to increment the count.
Parameters:
Return Value:
None.
Exceptions:
Throws TSemaphoreException(TSemaphoreException::kSemaphoreDeleted) if semaphore is being deleted.
Concurrency:
Multithread safe.
Other Considerations:
Any waiting threads are woken up in FIFO order.
virtual long GetCount () const
Interface Category:
API.
Purpose:
Provides a means of finding out the current count.
Calling Context:
Called to get the value of the semaphore count.
Parameters:
Return Value:
Current count at the time of the call.
Exceptions:
Throws TSemaphoreException(TSemaphoreException::kSemaphoreDeleted) if semaphore is being deleted.
Concurrency:
The count value is not safe to use, because of the concurrent access to the semaphore by multiple threads.
Other Considerations:
The value returned from this operation may not safe to use.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.