removed onThreadCreation; onThreadDestruction is now thread local

This commit is contained in:
Araq
2017-02-26 20:42:19 +01:00
parent df4954fac6
commit 4f062c3be0
3 changed files with 14 additions and 57 deletions

View File

@@ -7,19 +7,16 @@ var
someGlobal: string = "some string here"
perThread {.threadvar.}: string
proc setPerThread() =
{.gcsafe.}:
deepCopy(perThread, someGlobal)
proc threadDied() {.gcsafe} =
proc threadDied() {.gcsafe.} =
echo "dying ", perThread
proc foo() {.thread.} =
onThreadDestruction threadDied
{.gcsafe.}:
deepCopy(perThread, someGlobal)
echo perThread
proc main =
onThreadCreation setPerThread
onThreadDestruction threadDied
var t: Thread[void]
createThread[void](t, foo)
t.joinThread()