reactor-c
1.0
C Runtime for Lingua Franca
Toggle main menu visibility
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
28
typedef
struct
{
34
size_t
count
;
35
41
lf_mutex_t
mutex
;
42
48
lf_cond_t
cond
;
49
}
lf_semaphore_t
;
50
58
lf_semaphore_t
*
lf_semaphore_new
(
size_t
count);
59
67
void
lf_semaphore_release
(
lf_semaphore_t
* semaphore,
size_t
i);
68
75
void
lf_semaphore_acquire
(
lf_semaphore_t
* semaphore);
76
83
void
lf_semaphore_wait
(
lf_semaphore_t
* semaphore);
84
91
void
lf_semaphore_destroy
(
lf_semaphore_t
* semaphore);
92
93
#endif
// LF_SEMAPHORE_H
lf_semaphore_destroy
void lf_semaphore_destroy(lf_semaphore_t *semaphore)
Destroy the 'semaphore'.
lf_semaphore_wait
void lf_semaphore_wait(lf_semaphore_t *semaphore)
Wait on the 'semaphore' if count is 0.
lf_semaphore_new
lf_semaphore_t * lf_semaphore_new(size_t count)
Create a new semaphore.
lf_semaphore_acquire
void lf_semaphore_acquire(lf_semaphore_t *semaphore)
Acquire the 'semaphore'.
lf_semaphore_release
void lf_semaphore_release(lf_semaphore_t *semaphore, size_t i)
Release the 'semaphore' and add 'i' to its count.
low_level_platform.h
Platform API support for the C target of Lingua Franca.
lf_semaphore_t
A semaphore.
Definition
lf_semaphore.h:28
lf_semaphore_t::cond
lf_cond_t cond
Condition variable used for blocking operations.
Definition
lf_semaphore.h:48
lf_semaphore_t::mutex
lf_mutex_t mutex
Mutex used to protect access to the count.
Definition
lf_semaphore.h:41
lf_semaphore_t::count
size_t count
The current count of the semaphore.
Definition
lf_semaphore.h:34
Users
runner
work
reactor-c
reactor-c
include
core
utils
lf_semaphore.h
Generated on
for reactor-c by
1.17.0