Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v6-changes"></a>

## SRS 6.0 Changelog
* v6.0, 2024-03-24, Merge [#3989](https://github.com/ossrs/srs/pull/3989): ST: Research adds examples that demos pthread and helloworld. v6.0.118 (#3989)
* v6.0, 2024-03-19, Merge [#3958](https://github.com/ossrs/srs/pull/3958): Add a TCP proxy for debugging. v6.0.117 (#3958)
* v6.0, 2024-03-20, Merge [#3964](https://github.com/ossrs/srs/pull/3964): WebRTC: Add support for A/V only WHEP/WHEP player. v6.0.116 (#3964)
* v6.0, 2024-03-19, Merge [#3990](https://github.com/ossrs/srs/pull/3990): System: Disable feature that obtains versions and check features status. v6.0.115 (#3990)
Expand Down
29 changes: 29 additions & 0 deletions trunk/research/st/exceptions.cpp
Original file line number Diff line number Diff line change
@@ -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;
}

16 changes: 16 additions & 0 deletions trunk/research/st/hello-st.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
g++ hello-st.cpp ../../objs/st/libst.a -g -O0 -o hello-st && ./hello-st
*/
#include <stdio.h>
#include "../../objs/st/st.h"

void foo() {
st_init();
st_sleep(1);
printf("Hello World, ST!\n");
}

int main() {
foo();
return 0;
}
19 changes: 19 additions & 0 deletions trunk/research/st/hello-world.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
g++ hello-world.cpp ../../objs/st/libst.a -g -O0 -o hello-world && ./hello-world
*/
#include <stdio.h>
#include "../../objs/st/st.h"

void foo() {
st_init();

for (int i = 0; ; i++) {
st_sleep(1);
printf("#%d: main: working\n", i);
}
}

int main() {
foo();
return 0;
}
11 changes: 11 additions & 0 deletions trunk/research/st/hello.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
g++ hello.cpp -g -O0 -o hello && ./hello
*/

void foo() {
}

int main(int argc, char** argv) {
foo();
return 0;
}
36 changes: 36 additions & 0 deletions trunk/research/st/pthreads.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Directly compile c++ source and execute:
g++ pthreads.cpp ../../objs/st/libst.a -g -O0 -o pthreads && ./pthreads
*/
#include <stdio.h>
#include <pthread.h>
#include "../../objs/st/st.h"

void* foo(void* arg) {
while (true) {
printf("Hello, child thread\n");
st_sleep(1);
}
return NULL;
}

void* pfn(void* arg) {
st_init();
st_thread_create(foo, NULL, 0, 0);
st_thread_exit(NULL);
return NULL;
}

int main(int argc, char** argv) {
st_init();

pthread_t trd;
pthread_create(&trd, NULL, pfn, NULL);

while (true) {
printf("Hello, main thread\n");
st_sleep(1);
}
return 0;
}

2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 6
#define VERSION_MINOR 0
#define VERSION_REVISION 117
#define VERSION_REVISION 118

#endif
Loading