fixes #13781; fixes #14901; add acyclic pragmas to FlowVar (#20804)

* add acyclic pragmas to FlowVar

* add testcases
This commit is contained in:
ringabout
2022-11-10 16:54:39 +08:00
committed by GitHub
parent dac5a56d70
commit 2848cdb18a
2 changed files with 12 additions and 3 deletions

View File

@@ -102,7 +102,7 @@ type
idx: int
FlowVarBase* = ref FlowVarBaseObj ## Untyped base class for `FlowVar[T] <#FlowVar>`_.
FlowVarBaseObj = object of RootObj
FlowVarBaseObj {.acyclic.} = object of RootObj
ready, usesSemaphore, awaited: bool
cv: Semaphore # for 'blockUntilAny' support
ai: ptr AwaitInfo
@@ -111,7 +111,7 @@ type
# be RootRef here otherwise the wrong GC keeps track of it!
owner: pointer # ptr Worker
FlowVarObj[T] = object of FlowVarBaseObj
FlowVarObj[T] {.acyclic.} = object of FlowVarBaseObj
blob: T
FlowVar*[T] {.compilerproc.} = ref FlowVarObj[T] ## A data flow variable.

View File

@@ -4,7 +4,7 @@ done999 999
'''
"""
import threadpool
import std/[threadpool, os]
proc foo(): int = 999
@@ -17,3 +17,12 @@ proc main =
echo "done", f, " ", b
main()
# bug #13781
proc thread(): string =
os.sleep(1000)
return "ok"
var fv = spawn thread()
sync()
doAssert ^fv == "ok"