Skip to content

Commit

Permalink
Lazily initialize Future's ThreadPools.
Browse files Browse the repository at this point in the history
Lots of apps won't need them, or will only use one of them, so there's no need to pre-allocate both.
  • Loading branch information
player-03 committed Aug 12, 2024
1 parent 0fa7c57 commit 4b8f18b
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/lime/app/Future.hx
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,26 @@ enum FutureStatus<T>
#end
@:dox(hide) class FutureWork
{
public static var singleThread(default, null):FutureWork = new FutureWork(SINGLE_THREADED);
public static var singleThread(get, null):FutureWork;
private static inline function get_singleThread():FutureWork
{
if (singleThread == null)
{
singleThread = new FutureWork(SINGLE_THREADED);
}
return singleThread;
}

#if lime_threads
public static var multiThread(default, null):FutureWork = new FutureWork(MULTI_THREADED);
public static var multiThread(get, null):FutureWork;
private static inline function get_multiThread():FutureWork
{
if (multiThread == null)
{
multiThread = new FutureWork(MULTI_THREADED);
}
return multiThread;
}
#end

public static var totalActiveJobs(get, never):Int;
Expand Down

0 comments on commit 4b8f18b

Please sign in to comment.