Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ThreadPool to run jobs in both modes, and improve scheduling #1837

Open
wants to merge 14 commits into
base: 8.3.0-Dev
Choose a base branch
from
Prev Previous commit
Next Next commit
Improve ThreadPool.isMainThread().
No need to set `__mainThread` based on `isWorker()` when `isWorker()` already gives the information we're after.
  • Loading branch information
player-03 committed Dec 31, 2024
commit 8c9b17d43e9cac41d4e9049bcac19cddb49da012
13 changes: 5 additions & 8 deletions src/lime/system/ThreadPool.hx
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,14 @@ import lime._internal.backend.html5.HTML5Thread as Thread;
#end
class ThreadPool extends WorkOutput
{
#if (haxe4 && lime_threads)
#if (haxe4 && lime_threads && !html5)
/**
A thread or null value to be compared against `Thread.current()`. Don't
do anything with this other than check for equality.

Unavailable in Haxe 3 as thread equality checking doesn't work there.
**/
private static var __mainThread:Thread =
#if html5
!Thread.current().isWorker() ? Thread.current() : null;
#else
Thread.current();
#end
private static var __mainThread:Thread = Thread.current();
#end

/**
Expand All @@ -99,7 +94,9 @@ class ThreadPool extends WorkOutput
**/
public static inline function isMainThread():Bool
{
#if (haxe4 && lime_threads)
#if (html5 && lime_threads)
return !Thread.current().isWorker();
#elseif (haxe4 && lime_threads)
return Thread.current() == __mainThread;
#else
return true;
Expand Down