Skip to content

A simple implementation of Semaphore in C++11 using only Std library

License

Notifications You must be signed in to change notification settings

kevin-ye/CppSeamphore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CppSeamphore

A simple implementation of Semaphore in C++11 using only Std library

Usage

Copy both .hpp and .cpp into your project

Implementation

The seamphore is implemented to work in a very traditional way:

P() blocks until internal counter is greater than 0. V() increments the internal counter and signals waiting threads on P() to wake up.

Potential issues

Waiting and signaling is done by using condition variable in C++11 std, hence the order of waking up threads are not in FIFO order, causing potential bargin problem. Using this simple version of seamphore to synchronize massive amount of threads in a big project is not recommended.

About

A simple implementation of Semaphore in C++11 using only Std library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages