A server-side entry in TopGit's GitHub warehouse: ossrs/state-threads, 762 stars, Backend, C++. Lightweight thread library for C/C++ coroutine (similar to goroutine), for high performance network servers.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Native Windows x64 builds with the Visual Studio (MSVC) toolchain, cl, ml64, and lib, through GNU make
and the same Makefile. There is no Cygwin, MinGW, WSL, or POSIX emulation layer: GNU make and Git Bash only
run the build, and the output is the static library obj/libst.a built by MSVC. It needs Windows 10 1809 or
Windows Server 2019 or later, x64.
Install the build tools:
Visual Studio 2022, or its Build Tools, with the MSVC x64 tools (the "Desktop development with C++" workload).
Git for Windows, for Git Bash.
GNU make, for example winget install ezwinports.make or choco install make.
Open the x64 Native Tools Command Prompt for VS 2022, which runs vcvars64.bat and puts cl, ml64, and
lib on PATH, then start Git Bash in it:
"C:\Program Files\Git\bin\bash.exe"
For Windows, build the debug or the optimized library:
make win64-debug
make win64-optimized
Note: Programs that include st.h must include it before windows.h, or define WIN32_LEAN_AND_MEAN. The
library links ws2_32.lib by itself. For what works differently on Windows, read the
porting notes.
Windows with ASAN(Google Address Sanitizer), where cl has no -fno-omit-frame-pointer:
make win64-debug EXTRA_CFLAGS="-DMD_ASAN -fsanitize=address"
Remark: Cygwin64 is deprecated, do not use it. Use native Windows, as above.
Branch SRS
The branch srs was patched and refined. See CHANGELOG.md for the changes and versions.
GDB Tools
Support nn_coroutines, show number of coroutines.
Support show_coroutines, show all coroutines and caller function.
Valgrind
How to debug with gdb under valgrind, read valgrind manual.
About startup parameters, read valgrind cli.
Important cli options:
--undef-value-errors=<yes|no> [default: yes], Controls whether Memcheck reports uses of undefined value errors. Set this to no if you don't want to see undefined value errors. It also has the side effect of speeding up Memcheck somewhat.
--leak-check=<no|summary|yes|full> [default: summary], When enabled, search for memory leaks when the client program finishes. If set to summary, it says how many leaks occurred. If set to full or yes, each individual leak will be shown in detail and/or counted as an error, as specified by the options --show-leak-kinds and --errors-for-leak-kinds.
--track-origins=<yes|no> [default: no], Controls whether Memcheck tracks the origin of uninitialised values. By default, it does not, which means that although it can tell you that an uninitialised value is being used in a dangerous way, it cannot tell you where the uninitialised value came from. This often makes it difficult to track down the root problem.
--show-reachable=<yes|no> , --show-possibly-lost=<yes|no>, to show the using memory.
Linux: UTest
Note: We use Google test in utest/gtest-fit.
To make ST with utest and run it:
make linux-debug-utest && ./obj/st_utest
Note that the gcc(4.8) of CentOS is too old, please use docker(ossrs/srs:dev-gcc7) to run:
To make ST with utest and run it, in Git Bash with the MSVC environment (see Windows: Usage):
make win64-debug-utest && ./obj/st_utest.exe
The tests that need POSIX features (fork, signals, pipes, files) are not built on Windows, and a few are
skipped with a reason, for example the write tests that need a partial send, which Winsock never does.
To debug in Visual Studio, generate a solution with CMake, which comes with Visual Studio, from the
x64 Native Tools Command Prompt for VS 2022, then open C:\st-build\st.sln:
cmake -S cmake -B C:\st-build -G "Visual Studio 17 2022" -A x64
cmake --build C:\st-build --config Debug --target st_utest
Note: Use a short build directory, because MSBuild fails when its paths are too long. The Makefile stays the
main build, and CMake also builds the helloworld, porting, and verify tools.
Windows: Tools
The integration tools in tools/ build with MSVC and run with the same runner as on Linux and macOS, in Git
Bash with the MSVC environment (see Windows: Usage). It builds the library with
make -B win64-debug, then builds each tool and runs <name>.exe with ST_TOOL_EVENTSYS=select and alt
(both are WSAPoll on Windows), and prints All tools OK. Run it in the ST default build and in the SRS
build, as CI does:
The arguments name the tools to run, for example ./auto/tools.sh tcp udp. The runner leaves the library
built with EXTRA_CFLAGS, so rebuild with make -B win64-debug-utest before the utest.
On Windows, ST is sockets only, so the tools make each pipe a loopback TCP pair and each socketpair an
AF_UNIX stream pair, or a loopback UDP pair for datagrams. The pipe tool, which needs pipes, FIFOs,
st_open files, and signals, prints SKIP pipe: <why> instead of OK. A few checks that Windows does not
support are skipped there, each with a comment: the partial writes on timeout in tcp (Winsock never sends
part of a non-blocking send), the RLIMIT_NOFILE checks in lifecycle and stress, reading back
O_NONBLOCK in poll, and the AF_UNIX datagram echo and the ENOENT of a missing path in unix.
The exception tool is C++: it throws and catches C++ exceptions on coroutine stacks, and on Windows also
raises and catches SEH exceptions there. Windows builds C++ exceptions on SEH, which rejects frames outside
the stack bounds in the TIB, so this works only because ST switches those bounds with each coroutine stack.
Every CPU: QEMU and Rosetta
Every CPU starts a new coroutine in a small assembly entry, _st_md_thread_start; read
docs/coroutine_entry.md for how. To test the CPUs this machine cannot run, build
for them and run the utest and the tools with QEMU user mode, in Docker:
./auto/qemu.sh riscv64
./auto/qemu.sh mips utest
The CPUs are x86_64, aarch64, i386, arm, riscv64, loongarch64, mips, mipsel, mips64, and
mips64el. The second argument picks utest, tools (auto/tools.sh), tools-malloc (with
EXTRA_CFLAGS=-DMALLOC_STACK), asan (the utest and the tools with ASAN, in LINUX_<cpu>_asan_DBG), or
all, the default. The script builds a local Docker image from auto/qemu/Dockerfile (the cross compilers of
Ubuntu 24.04, and the static qemu-user 10.2 of Ubuntu 26.04) when it is missing. Its tag, st-qemu:<hash>, is
a short hash of the files in auto/qemu/, so editing the Dockerfile builds a new image; the script then removes
the older ones, except one that a container still uses. It builds everything in place in LINUX_<cpu>_qemu_DBG, the utest and the tools too, and
leaves the obj link alone, so two CPUs can run at once in one checkout. It prints one
RESULT <cpu> <run> PASS|FAIL line per run. A CPU that is the container's own runs natively. On a Docker host
of another CPU, such as Apple Silicon, x86_64 runs in an amd64 container, st-qemu:<hash>-amd64, which
Docker emulates as a whole. Every other CPU runs with qemu-user, which is slower than the real CPU, and skips asan with a SKIP line.
To test every CPU at once, use all instead of a CPU, with the same second argument:
./auto/qemu.sh all
ST_QEMU_JOBS=10 ./auto/qemu.sh all utest
It builds the images once, then runs each CPU in its own container, at most ST_QEMU_JOBS at once (5 by
default), with its output in /tmp/st-qemu-all/<cpu>.log. At the end it prints a summary, one row per CPU with
PASS or FAIL and the seconds of each run, and the wall time, then the end of the log of each CPU that failed,
and exits 1 when any CPU failed. ST_QEMU_CPUS picks the CPUs, such as ST_QEMU_CPUS="mips mipsel" ./auto/qemu.sh all. Every compile goes
through ccache, with its cache in ~/.cache/st-qemu-ccache (or ST_QEMU_CCACHE), so a second run compiles
only what changed; all ends with the ccache stats. CI runs the eight CPUs that no native job runs, four in
each of the actions-test-qemu-misc and actions-test-qemu-mips jobs, with the ccache kept between runs.
To build, run and debug a CPU by hand, ./auto/qemu.sh <cpu> shell opens a bash in the image with the CPU's
toolchain exported. The image has gdb-multiarch: start the program under the gdb stub of qemu-user, then
attach to it, as the header of auto/qemu.sh shows:
On macOS, build and run for either CPU; on Apple Silicon, x86_64 runs under Rosetta 2:
./auto/darwin.sh arm64
./auto/darwin.sh x86_64
It takes the same second argument, and builds everything in place in DARWIN_<cpu>_DBG. For Windows x64,
run the utest and the tools natively, as in Windows: UTest and Windows: Tools.
Linux: Coverage
Note: We use Google test in utest/gtest-fit.
To make ST with utest and run it:
make linux-debug-gcov && ./obj/st_utest
Note that the gcc(4.8) of CentOS is too old, please use docker(ossrs/srs:dev-gcc7) to run:
The most recent commit recorded on ossrs/state-threads was 1.1 years ago, based on the GitHub push timestamp. The repository has 278 forks — one of the better signals of community interest.
How does ossrs/state-threads compare to other Backend projects?
ossrs/state-threads is tracked by TopGit in the Backend category, with 762 GitHub stars and written in C++. Browse the Backend topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does ossrs/state-threads have?
ossrs/state-threads has 762 GitHub stars — refresh the page for the live number, or check github.com/ossrs/state-threads. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What is ossrs/state-threads?
ossrs/state-threads (ossrs/state-threads) is a C++ project on GitHub. From the project's own README: Lightweight thread library for C/C++ coroutine (similar to goroutine), for high performance network servers.
What language is ossrs/state-threads written in?
ossrs/state-threads is written primarily in C++. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is ossrs/state-threads associated with?
Why is ossrs/state-threads categorized under Backend?
TopGit places ossrs/state-threads in the Backend category based on its GitHub topics and description (tagged: "async", "asyncio", "c"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Want a second opinion on state-threads?
Ask an AI that can read this page — one click and you get its take on state-threads.