MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / run

Function run

src/hx/thread/ThreadImpl.cpp:39–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37 std::atomic_int nextThreadnumber(0);
38
39 void run(hx::thread::ThreadImpl thread, hx::thread::Thread_obj::CreateFunction job, hx::thread::CountingSemaphore semaphore)
40 {
41 // info[1] will the the "top of stack" - values under this
42 // (ie info[0] and other stack values) will be in the GC conservative range
43 //
44 // I'm assuming the array of two elements is some trick to ensure it's on the stack.
45 // Maybe we could use OS specific functions to get the stack range?
46
47 auto root = new hx::Object* { thread.GetPtr() };
48
49 hx::GCAddRoot(root);
50
51 tls.set(root);
52
53 auto info = std::array<hx::thread::ThreadImpl_obj*, 2>{ thread.GetPtr(), nullptr };
54
55 hx::SetTopOfStack(reinterpret_cast<int*>(&info[1]), true);
56
57 // Release the creation function
58 semaphore->release();
59
60 job();
61
62 hx::UnregisterCurrentThread();
63 }
64}
65
66hx::thread::Thread hx::thread::Thread_obj::create(CreateFunction job)

Callers 15

runVoidMethod · 0.85
runIntMethod · 0.85
runFloatMethod · 0.85
runStringMethod · 0.85
runObjectMethod · 0.85
runVoidMethod · 0.85
runIntMethod · 0.85
runFloatMethod · 0.85
runStringMethod · 0.85
runObjectMethod · 0.85
runVoidMethod · 0.85
runIntMethod · 0.85

Calls 5

SetTopOfStackFunction · 0.85
UnregisterCurrentThreadFunction · 0.85
GetPtrMethod · 0.80
setMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected