Skip to content

Commit

Permalink
Windows: Support run in single thread mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 19, 2022
1 parent efea38c commit 3d0dcb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions trunk/auto/auto_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ if [[ $SRS_LOG_TRACE == YES ]]; then
else
srs_undefine_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SINGLE_THREAD == YES ]]; then
srs_define_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_LOG_LEVEL_V2 == YES ]]; then
srs_define_macro "SRS_LOG_LEVEL_V2" $SRS_AUTO_HEADERS_H
else
Expand Down
4 changes: 4 additions & 0 deletions trunk/auto/options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ SRS_BUILD_TAG= # Set the object files tag name.
SRS_CLEAN=YES # Whether do "make clean" when configure.
SRS_SIMULATOR=NO # Whether enable RTC simulate API.
SRS_GENERATE_OBJS=NO # Whether generate objs and quit.
SRS_SINGLE_THREAD=NO # Whether force single thread mode.
#
################################################################
# Performance options.
Expand Down Expand Up @@ -184,6 +185,7 @@ Experts:
--clean=on|off Whether do 'make clean' when configure. Default: $(value2switch $SRS_CLEAN)
--simulator=on|off RTC: Whether enable network simulator. Default: $(value2switch $SRS_SIMULATOR)
--generate-objs=on|off RTC: Whether generate objs and quit. Default: $(value2switch $SRS_GENERATE_OBJS)
--single-thread=on|off Whether force single thread mode. Default: $(value2switch $SRS_SINGLE_THREAD)
--build-tag=<TAG> Set the build object directory suffix.
Workflow:
Expand Down Expand Up @@ -298,6 +300,7 @@ function parse_user_option() {
--rtc) SRS_RTC=$(switch2value $value) ;;
--simulator) SRS_SIMULATOR=$(switch2value $value) ;;
--generate-objs) SRS_GENERATE_OBJS=$(switch2value $value) ;;
--single-thread) SRS_SINGLE_THREAD=$(switch2value $value) ;;
--ffmpeg-fit) SRS_FFMPEG_FIT=$(switch2value $value) ;;
--gb28181) SRS_GB28181=$(switch2value $value) ;;

Expand Down Expand Up @@ -586,6 +589,7 @@ function regenerate_options() {
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug-stats=$(value2switch $SRS_DEBUG_STATS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cross-build=$(value2switch $SRS_CROSS_BUILD)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer=$(value2switch $SRS_SANITIZER)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --single-thread=$(value2switch $SRS_SINGLE_THREAD)"
if [[ $SRS_CROSS_BUILD_ARCH != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --arch=$SRS_CROSS_BUILD_ARCH"; fi
if [[ $SRS_CROSS_BUILD_CPU != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --cpu=$SRS_CROSS_BUILD_CPU"; fi
if [[ $SRS_CROSS_BUILD_HOST != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --host=$SRS_CROSS_BUILD_HOST"; fi
Expand Down
5 changes: 5 additions & 0 deletions trunk/src/main/srs_main_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ srs_error_t run_directly_or_daemon()
srs_error_t run_hybrid_server(void* arg);
srs_error_t run_in_thread_pool()
{
#ifdef SRS_SINGLE_THREAD
srs_trace("Run in single thread mode");
return run_hybrid_server(NULL);
#else
srs_error_t err = srs_success;

// Initialize the thread pool.
Expand All @@ -490,6 +494,7 @@ srs_error_t run_in_thread_pool()
srs_trace("Pool: Start threads primordial=1, hybrids=1 ok");

return _srs_thread_pool->run();
#endif
}

#include <srs_app_tencentcloud.hpp>
Expand Down

0 comments on commit 3d0dcb2

Please sign in to comment.