|
Kore 3
|
A semaphore is a fancier version of an event that includes a counter to control how many threads are allowed to work on a task. More...
Go to the source code of this file.
Data Structures | |
| struct | kore_semaphore |
Typedefs | |
| typedef struct kore_semaphore | kore_semaphore |
Functions | |
| KORE_FUNC void | kore_semaphore_init (kore_semaphore *semaphore, int current, int max) |
| Initializes a semaphore. | |
| KORE_FUNC void | kore_semaphore_destroy (kore_semaphore *semaphore) |
| Destroys a semaphore. | |
| KORE_FUNC void | kore_semaphore_release (kore_semaphore *semaphore, int count) |
| Increases the current count of the semaphore, therefore allowing more acquires to succeed. | |
| KORE_FUNC void | kore_semaphore_acquire (kore_semaphore *semaphore) |
| Decreases the count of the semaphore by one. Blocks until it is possible to decrease the count if it already reached zero. | |
| KORE_FUNC bool | kore_semaphore_try_to_acquire (kore_semaphore *semaphore, double timeout) |
| Attempts to decrease the count of the semaphore by one. | |
A semaphore is a fancier version of an event that includes a counter to control how many threads are allowed to work on a task.
| KORE_FUNC void kore_semaphore_acquire | ( | kore_semaphore * | semaphore | ) |
Decreases the count of the semaphore by one. Blocks until it is possible to decrease the count if it already reached zero.
| semaphore | The semaphore to acquire |
| KORE_FUNC void kore_semaphore_destroy | ( | kore_semaphore * | semaphore | ) |
Destroys a semaphore.
| semaphore | The semaphore to destroy |
| KORE_FUNC void kore_semaphore_init | ( | kore_semaphore * | semaphore, |
| int | current, | ||
| int | max ) |
Initializes a semaphore.
| semaphore | The semaphore to initialize |
| current | The current count of the semaphore |
| max | The maximum allowed count of the semaphore |
| KORE_FUNC void kore_semaphore_release | ( | kore_semaphore * | semaphore, |
| int | count ) |
Increases the current count of the semaphore, therefore allowing more acquires to succeed.
| semaphore | The semaphore to increase the count on |
| count | The amount by which the count will be increased |
| KORE_FUNC bool kore_semaphore_try_to_acquire | ( | kore_semaphore * | semaphore, |
| double | timeout ) |
Attempts to decrease the count of the semaphore by one.
| semaphore | The semaphore to acquire |
| timeout | The timeout in seconds after which the function returns if the semaphore-count could not be decreased |