diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp index e217c2e610e..fe2a685a761 100644 --- a/src/rt/rust_task_thread.cpp +++ b/src/rt/rust_task_thread.cpp @@ -13,13 +13,15 @@ pthread_key_t rust_task_thread::task_key; DWORD rust_task_thread::task_key; #endif -const size_t C_STACK_SIZE = (1024*1024); +const size_t SCHED_STACK_SIZE = 1024*100; +const size_t C_STACK_SIZE = 1024*1024; bool rust_task_thread::tls_initialized = false; rust_task_thread::rust_task_thread(rust_scheduler *sched, rust_srv *srv, int id) : + rust_thread(SCHED_STACK_SIZE), ref_count(1), _log(srv, this), log_lvl(log_debug), diff --git a/src/rt/sync/rust_thread.cpp b/src/rt/sync/rust_thread.cpp index 3c54fdcf3f4..df0d57767df 100644 --- a/src/rt/sync/rust_thread.cpp +++ b/src/rt/sync/rust_thread.cpp @@ -1,7 +1,13 @@ #include "globals.h" #include "rust_thread.h" -rust_thread::rust_thread() : thread(0) { +const size_t default_stack_sz = 1024*1024; + +rust_thread::rust_thread() : thread(0), stack_sz(default_stack_sz) { +} + +rust_thread::rust_thread(size_t stack_sz) + : thread(0), stack_sz(stack_sz) { } rust_thread::~rust_thread() { @@ -23,11 +29,11 @@ rust_thread_start(void *ptr) { void rust_thread::start() { #if defined(__WIN32__) - thread = CreateThread(NULL, 0, rust_thread_start, this, 0, NULL); + thread = CreateThread(NULL, stack_sz, rust_thread_start, this, 0, NULL); #else pthread_attr_t attr; pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, 1024 * 1024); + pthread_attr_setstacksize(&attr, stack_sz); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); pthread_create(&thread, &attr, rust_thread_start, (void *) this); #endif diff --git a/src/rt/sync/rust_thread.h b/src/rt/sync/rust_thread.h index 2e143110c28..cdb1346bb2b 100644 --- a/src/rt/sync/rust_thread.h +++ b/src/rt/sync/rust_thread.h @@ -5,13 +5,17 @@ * Thread utility class. Derive and implement your own run() method. */ class rust_thread { -public: + private: #if defined(__WIN32__) HANDLE thread; #else pthread_t thread; #endif + size_t stack_sz; + public: + rust_thread(); + rust_thread(size_t stack_sz); virtual ~rust_thread(); void start();