mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 14:55:24 +00:00
progress with futures
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
discard """
|
||||
output: '''4
|
||||
8'''
|
||||
cmd: "nimrod $target --threads:on $options $file"
|
||||
"""
|
||||
|
||||
import threadpool
|
||||
|
||||
var
|
||||
x, y = 0
|
||||
|
||||
proc p1 =
|
||||
for i in 0 .. 10_000:
|
||||
discard
|
||||
|
||||
atomicInc x
|
||||
|
||||
proc p2 =
|
||||
for i in 0 .. 10_000:
|
||||
discard
|
||||
|
||||
atomicInc y, 2
|
||||
|
||||
for i in 0.. 3:
|
||||
spawn(p1())
|
||||
spawn(p2())
|
||||
|
||||
sync()
|
||||
|
||||
echo x
|
||||
echo y
|
||||
@@ -1,9 +0,0 @@
|
||||
discard """
|
||||
line: 7
|
||||
errormsg: "'spawn' takes a call expression of type void"
|
||||
cmd: "nimrod $target --threads:on $options $file"
|
||||
"""
|
||||
|
||||
import threadpool
|
||||
|
||||
spawn(1)
|
||||
Reference in New Issue
Block a user