From 8942c86eb5c0947f274807580dc8708020b96139 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Mon, 18 Mar 2024 05:43:03 -0400 Subject: [PATCH] ThreadPool.MaxStackSize --- BeefLibs/corlib/src/Threading/Thread.bf | 4 ++-- BeefLibs/corlib/src/Threading/ThreadPool.bf | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/BeefLibs/corlib/src/Threading/Thread.bf b/BeefLibs/corlib/src/Threading/Thread.bf index b6fb4de6..3d3861b5 100644 --- a/BeefLibs/corlib/src/Threading/Thread.bf +++ b/BeefLibs/corlib/src/Threading/Thread.bf @@ -148,7 +148,7 @@ namespace System.Threading SetStart((Delegate)start, 0); //0 will setup Thread with default stackSize } - public this(ThreadStart start, int32 maxStackSize) + public this(ThreadStart start, int maxStackSize) { if (start == null) { @@ -156,7 +156,7 @@ namespace System.Threading } if (0 > maxStackSize) Runtime.FatalError(); - SetStart((Delegate)start, maxStackSize); + SetStart((Delegate)start, (.)maxStackSize); } public this(ParameterizedThreadStart start) diff --git a/BeefLibs/corlib/src/Threading/ThreadPool.bf b/BeefLibs/corlib/src/Threading/ThreadPool.bf index 7b50530f..9338ee3b 100644 --- a/BeefLibs/corlib/src/Threading/ThreadPool.bf +++ b/BeefLibs/corlib/src/Threading/ThreadPool.bf @@ -40,8 +40,15 @@ namespace System.Threading static ThreadStats sWorkerThreadStats; static ThreadStats sIOThreadStats; + static int sMaxStackSize; static List mWorkEntries = new List() ~ delete _; + public static int MaxStackSize + { + get => sMaxStackSize; + set => sMaxStackSize = value; + } + static this() { //TODO: This is really bad, fix this pool! @@ -76,7 +83,7 @@ namespace System.Threading sWorkerThreadStats.mCount++; sWorkerThreadStats.mActive++; // We know the thread will immediately become active - Thread thread = new Thread(new () => { WorkerProc(threadId); }); + Thread thread = new Thread(new () => { WorkerProc(threadId); }, sMaxStackSize); sThreads.Add(thread); thread.Start(false); }