Skip to content

Commit 3a77227

Browse files
author
Aidan Lee
committed
Add haxe 4 dynamic fallback
1 parent 4da005b commit 3a77227

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

include/hx/thread/Thread.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ namespace hx
1212
{
1313
struct Thread_obj : public hx::Object
1414
{
15-
static Thread create(Callable<void(void)> job);
15+
using CreateFunction =
16+
#if (HXCPP_API_LEVEL >= 500)
17+
Callable<void(void)>;
18+
#else
19+
Dynamic;
20+
#endif
21+
22+
static Thread create(CreateFunction);
1623
static Thread current();
1724
static int id();
1825

src/hx/thread/ThreadImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace
3636

3737
std::atomic_int nextThreadnumber(0);
3838

39-
void run(hx::thread::ThreadImpl thread, hx::Callable<void(void)> job, hx::thread::CountingSemaphore semaphore)
39+
void run(hx::thread::ThreadImpl thread, hx::thread::Thread_obj::CreateFunction job, hx::thread::CountingSemaphore semaphore)
4040
{
4141
// info[1] will the the "top of stack" - values under this
4242
// (ie info[0] and other stack values) will be in the GC conservative range
@@ -59,7 +59,7 @@ namespace
5959
}
6060
}
6161

62-
hx::thread::Thread hx::thread::Thread_obj::create(Callable<void(void)> job)
62+
hx::thread::Thread hx::thread::Thread_obj::create(CreateFunction job)
6363
{
6464
#ifdef EMSCRIPTEN
6565
return hx::Throw(HX_CSTRING("Threads are not supported on Emscripten"));

0 commit comments

Comments
 (0)