reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
lf_semaphore.h
Go to the documentation of this file.
1
8
9#ifndef LF_SEMAPHORE_H
10#define LF_SEMAPHORE_H
11
12#ifndef NUMBER_OF_WORKERS
13#define NUMBER_OF_WORKERS 1
14#endif // NUMBER_OF_WORKERS
15
16#include "low_level_platform.h"
17#include <stdlib.h>
18
28typedef struct {
34 size_t count;
35
41 lf_mutex_t mutex;
42
48 lf_cond_t cond;
50
59
67void lf_semaphore_release(lf_semaphore_t* semaphore, size_t i);
68
76
84
92
93#endif // LF_SEMAPHORE_H
void lf_semaphore_destroy(lf_semaphore_t *semaphore)
Destroy the 'semaphore'.
void lf_semaphore_wait(lf_semaphore_t *semaphore)
Wait on the 'semaphore' if count is 0.
lf_semaphore_t * lf_semaphore_new(size_t count)
Create a new semaphore.
void lf_semaphore_acquire(lf_semaphore_t *semaphore)
Acquire the 'semaphore'.
void lf_semaphore_release(lf_semaphore_t *semaphore, size_t i)
Release the 'semaphore' and add 'i' to its count.
Platform API support for the C target of Lingua Franca.
A semaphore.
Definition lf_semaphore.h:28
lf_cond_t cond
Condition variable used for blocking operations.
Definition lf_semaphore.h:48
lf_mutex_t mutex
Mutex used to protect access to the count.
Definition lf_semaphore.h:41
size_t count
The current count of the semaphore.
Definition lf_semaphore.h:34