2020-12-27 16:02:35 +03:00
|
|
|
#include "sc_cond.h"
|
2020-11-16 03:58:37 +03:00
|
|
|
|
2020-12-27 16:02:35 +03:00
|
|
|
#include <stdio.h>
|
2020-11-16 03:58:37 +03:00
|
|
|
|
2023-03-19 21:54:21 +03:00
|
|
|
int main(void)
|
2020-11-16 03:58:37 +03:00
|
|
|
{
|
2021-04-07 00:28:50 +03:00
|
|
|
struct sc_cond cond;
|
2020-12-27 16:02:35 +03:00
|
|
|
|
2021-04-07 00:28:50 +03:00
|
|
|
sc_cond_init(&cond); // Init once
|
2021-02-06 21:36:18 +03:00
|
|
|
|
2021-04-07 00:28:50 +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
|
|
|
|
2021-04-07 00:28:50 +03:00
|
|
|
printf("%s \n", p); // Prints "test"
|
2021-02-06 21:36:18 +03:00
|
|
|
|
2021-04-07 00:28:50 +03:00
|
|
|
sc_cond_term(&cond); // Destroy
|
2020-12-27 16:02:35 +03:00
|
|
|
|
2021-04-07 00:28:50 +03:00
|
|
|
return 0;
|
2020-11-16 03:58:37 +03:00
|
|
|
}
|