1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/research/st/st-cond.cpp
Winlin ff6a608099
ST: Replace macros with explicit code for better understanding. v7.0.7 (#4149)
Improvements for ST(State Threads):

1. ST: Use g++ for CXX compiler.
2. ST: Remove macros for clist.
3. ST: Remove macros for global thread and vp.
4. ST: Remove macros for vp queue operations.
5. ST: Remove macros for context switch.
6. ST: Remove macros for setjmp/longjmp.
7. ST: Remove macro for stack pad.
8. ST: Refine macro for valgrind.

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-08-22 11:28:25 +08:00

26 lines
437 B
C++

/*
g++ st-cond.cpp ../../objs/st/libst.a -g -O0 -o st-cond && ./st-cond
*/
#include <stdio.h>
#include "../../objs/st/st.h"
st_cond_t lock;
void* foo(void*) {
st_cond_wait(lock);
printf("Hello World, ST!\n");
return NULL;
}
int main() {
st_init();
lock = st_cond_new();
st_thread_create(foo, NULL, 0, 0);
st_sleep(1);
st_cond_signal(lock);
st_sleep(1);
st_cond_destroy(lock);
return 0;
}