[std/tasks]add gcsafe pragmas (#17799)
* [std/tasks]add gcsafe pragmas * Update tasks.nim
This commit is contained in:
parent
eb221dcc27
commit
603af22b7c
1 changed files with 4 additions and 4 deletions
|
|
@ -59,7 +59,7 @@ when compileOption("threads"):
|
||||||
|
|
||||||
type
|
type
|
||||||
Task* = object ## `Task` contains the callback and its arguments.
|
Task* = object ## `Task` contains the callback and its arguments.
|
||||||
callback: proc (args: pointer) {.nimcall.}
|
callback: proc (args: pointer) {.nimcall, gcsafe.}
|
||||||
args: pointer
|
args: pointer
|
||||||
destroy: proc (args: pointer) {.nimcall.}
|
destroy: proc (args: pointer) {.nimcall.}
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ proc `=destroy`*(t: var Task) {.inline.} =
|
||||||
t.destroy(t.args)
|
t.destroy(t.args)
|
||||||
c_free(t.args)
|
c_free(t.args)
|
||||||
|
|
||||||
proc invoke*(task: Task) {.inline.} =
|
proc invoke*(task: Task) {.inline, gcsafe.} =
|
||||||
## Invokes the `task`.
|
## Invokes the `task`.
|
||||||
assert task.callback != nil
|
assert task.callback != nil
|
||||||
task.callback(task.args)
|
task.callback(task.args)
|
||||||
|
|
@ -215,7 +215,7 @@ macro toTask*(e: typed{nkCall | nkInfix | nkPrefix | nkPostfix | nkCommand | nkC
|
||||||
result = quote do:
|
result = quote do:
|
||||||
`stmtList`
|
`stmtList`
|
||||||
|
|
||||||
proc `funcName`(args: pointer) {.nimcall.} =
|
proc `funcName`(args: pointer) {.gcsafe, nimcall.} =
|
||||||
let `objTemp` = cast[ptr `scratchObjType`](args)
|
let `objTemp` = cast[ptr `scratchObjType`](args)
|
||||||
`functionStmtList`
|
`functionStmtList`
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ macro toTask*(e: typed{nkCall | nkInfix | nkPrefix | nkPostfix | nkCommand | nkC
|
||||||
let funcName = genSym(nskProc, e[0].strVal)
|
let funcName = genSym(nskProc, e[0].strVal)
|
||||||
|
|
||||||
result = quote do:
|
result = quote do:
|
||||||
proc `funcName`(args: pointer) {.nimcall.} =
|
proc `funcName`(args: pointer) {.gcsafe, nimcall.} =
|
||||||
`funcCall`
|
`funcCall`
|
||||||
|
|
||||||
Task(callback: `funcName`, args: nil)
|
Task(callback: `funcName`, args: nil)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue