removed onThreadCreation; onThreadDestruction is now thread local
This commit is contained in:
parent
df4954fac6
commit
4f062c3be0
3 changed files with 14 additions and 57 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue