Files
Nim/tests/threads/treusetvar.nim
ringabout cdbf5b4699 fixes a severe bug of testament (#20832)
* test azure

* use exit 1

* try again

* use useSysAssert

* disable i386

* use refc for tlsEmulation on i386

* use refc

* disable i386

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-11-17 09:38:07 +08:00

30 lines
470 B
Nim

discard """
disabled: i386
outputsub: "65"
"""
import locks
type
MarkerObj = object
lock: Lock
counter: int
Marker = ptr MarkerObj
const
ThreadsCount = 65
proc worker(p: Marker) {.thread.} =
acquire(p.lock)
inc(p.counter)
release(p.lock)
var p = cast[Marker](allocShared0(sizeof(MarkerObj)))
initLock(p.lock)
for i in 0..(ThreadsCount - 1):
var thread: Thread[Marker]
createThread(thread, worker, p)
joinThread(thread)
echo p.counter