sc/condition/cond_example.c

20 lines
326 B
C
Raw Normal View History

2020-12-27 16:02:35 +03:00
#include "sc_cond.h"
2020-12-27 16:02:35 +03:00
#include <stdio.h>
2023-03-19 21:54:21 +03:00
int main(void)
{
struct sc_cond cond;
2020-12-27 16:02:35 +03:00
sc_cond_init(&cond); // Init once
2021-02-06 21:36:18 +03:00
sc_cond_signal(&cond, "test"); // Call this on thread-1
char *p = sc_cond_wait(&cond); // Call this on another thread.
2020-12-27 16:02:35 +03:00
printf("%s \n", p); // Prints "test"
2021-02-06 21:36:18 +03:00
sc_cond_term(&cond); // Destroy
2020-12-27 16:02:35 +03:00
return 0;
}