mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
25 lines
426 B
Nim
25 lines
426 B
Nim
discard """
|
|
output: '''some string here
|
|
dying some string here'''
|
|
"""
|
|
|
|
var
|
|
someGlobal: string = "some string here"
|
|
perThread {.threadvar.}: string
|
|
|
|
proc threadDied() {.gcsafe.} =
|
|
echo "dying ", perThread
|
|
|
|
proc foo() {.thread.} =
|
|
onThreadDestruction threadDied
|
|
{.gcsafe.}:
|
|
deepCopy(perThread, someGlobal)
|
|
echo perThread
|
|
|
|
proc main =
|
|
var t: Thread[void]
|
|
createThread[void](t, foo)
|
|
t.joinThread()
|
|
|
|
main()
|