Add tests for examples from Nim in Action.
This commit is contained in:
parent
a585748f27
commit
7889c03cbc
34 changed files with 1213 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
import threadpool, locks
|
||||
|
||||
var counterLock: Lock
|
||||
initLock(counterLock)
|
||||
var counter {.guard: counterLock.} = 0
|
||||
|
||||
proc increment(x: int) =
|
||||
for i in 0 .. <x:
|
||||
let value = counter + 1
|
||||
counter = value
|
||||
|
||||
spawn increment(10_000)
|
||||
spawn increment(10_000)
|
||||
sync()
|
||||
echo(counter)
|
||||
Loading…
Add table
Add a link
Reference in a new issue