1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

ST: Research adds examples that demos pthread and helloworld. v6.0.118 (#3989)

1. `trunk/research/st/exceptions.cpp` About exceptions with ST, works
well on linux and mac, not work on cygwin.
2. `trunk/research/st/pthreads.cpp` About pthreads with ST, works well
on all platforms.
3. `trunk/research/st/hello.cpp` Hello world, without ST, works well on
all platforms.
4. `trunk/research/st/hello-world.cpp` Hello world, with ST, works well
on all platforms.
5. `trunk/research/st/hello-st.cpp` A very simple version for hello
world with ST, works well on all platforms.
This commit is contained in:
Winlin 2024-03-24 09:28:46 +08:00 committed by GitHub
parent ce2ce1542f
commit ff91757a3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 113 additions and 1 deletions

View file

@ -0,0 +1,29 @@
/*
# !!! ST does not support C++ exceptions on cygwin !!!
g++ exceptions.cpp ../../objs/st/libst.a -g -O0 -o exceptions && ./exceptions
*/
#include <stdio.h>
#include <exception>
#include "../../objs/st/st.h"
int handle_exception() {
try {
throw 3;
} catch (...) {
return 5;
}
}
void* foo(void* arg) {
int r0 = handle_exception();
printf("r0=%d\n", r0);
return NULL;
}
int main(int argc, char** argv) {
st_init();
st_thread_create(foo, NULL, 0, 0);
st_thread_exit(NULL);
return 0;
}