|
AXCEL C++ Framework
Elegance through abstraction
|
Semaphore. More...
#include <axcel.h>
Public Member Functions | |
| virtual string | type () |
| Get type of object. | |
| virtual | operator string () |
| Convert to string. | |
| semaphore () | |
| semaphore (size_t count) | |
| semaphore (const char *name) | |
| ~semaphore () | |
| bool | init (size_t count) |
| bool | die () |
| bool | open (const char *name) |
| bool | close () |
| bool | get (size_t ms=0) |
| bool | tryget () |
| bool | ret () |
Public Attributes | |
| sem_t * | id |
| bool | named |
Semaphore.
Semaphores allow processes and threads to synchronize their actions. Think of a semaphore as a rental service, there's a set amount of items to lend to threads/processes. Once there's no more items to lend out to someone, that person will wait until someone else who is renting one of those items returns it. Likewise a semaphore is an integer; each thread that wants to access an associated resource will first decrement this integer. Once that thread is done with the resource, it will increment the semaphore. If a thread tries to decrement a semaphore whose value is zero, then that thread will block (or fail to access the resource if non-blocking) until another thread releases the resource and increments the semaphore.
| axcel::proc::semaphore::operator string | ( | ) | [virtual] |
Convert to string.
Implements axcel::object.
| string axcel::proc::semaphore::type | ( | ) | [virtual] |
| sem_t* axcel::proc::semaphore::id |
1.7.4