Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

StaticSemaphore

 

class Semaphore

Well known multithreading synchronization tool. In U++, it is primarily used to block and release thread execution. Semaphore has an internal counter, initially initialized to zero. Wait operation blocks thread execution as long as counter is zero, then decreases it by one. Release operation increases counter by 1.

 

 

Public Method List

 

void Wait()

If internal semaphore counter is zero, waits (blocks calling thread) until some other thread increases this counter by 1 calling the Release method. Before returning, decreases counter by 1.

 


 

void Release()

Increases internal counter by 1.

 

 

Constructor detail

 

Semaphore()

Initializes internal counter to 0.

 

 

 

 

StaticSemaphore

 

class StaticSemaphore

Variant of Semaphore that can be used as static or global variable without the need of initialization  - it has no constructor and correctly performs the first initialization when any of methods is called. That avoids problems with initialization order or multithreaded initialization issues.

 

 

Public Method List

 

Semaphore& Get()

operator Semaphore&()

Returns the Semaphore instance.

 


 

void Wait()

void Release()

Call respective methods of Semaphore instance.

 

 

Last edit by cxl on 02/11/2016. Do you want to contribute?. T++