mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-06 05:37:48 +00:00
GEEKING
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace Roblox
|
||||
{
|
||||
public static class RobloxThreadPool
|
||||
{
|
||||
private static int _QueueLength;
|
||||
|
||||
public static int QueueLength { get { return _QueueLength; } }
|
||||
|
||||
public static void GetAvailableThreads(out int workerThreads, out int completionPortThreads)
|
||||
=> ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads);
|
||||
|
||||
public static bool QueueUserWorkItem(Action callback)
|
||||
{
|
||||
Interlocked.Increment(ref _QueueLength);
|
||||
return ThreadPool.QueueUserWorkItem((s) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
callback();
|
||||
}
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionHandler.LogException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interlocked.Decrement(ref _QueueLength);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user