[std/tasks] more gcsafe stuffs [backport] (#18926)

This commit is contained in:
flywind 2021-09-30 13:46:30 +08:00 • committed by GitHub
commit 6bb32da4ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -61,12 +61,12 @@ type
Task* = object ## `Task` contains the callback and its arguments. Task* = object ## `Task` contains the callback and its arguments.
callback: proc (args: pointer) {.nimcall, gcsafe.} callback: proc (args: pointer) {.nimcall, gcsafe.}
args: pointer args: pointer
destroy: proc (args: pointer) {.nimcall.} destroy: proc (args: pointer) {.nimcall, gcsafe.}
proc `=copy`*(x: var Task, y: Task) {.error.} proc `=copy`*(x: var Task, y: Task) {.error.}
proc `=destroy`*(t: var Task) {.inline.} = proc `=destroy`*(t: var Task) {.inline, gcsafe.} =
## Frees the resources allocated for a `Task`. ## Frees the resources allocated for a `Task`.
if t.args != nil: if t.args != nil:
if t.destroy != nil: if t.destroy != nil:
@ -219,7 +219,7 @@ macro toTask*(e: typed{nkCall | nkInfix | nkPrefix | nkPostfix | nkCommand | nkC
let `objTemp` = cast[ptr `scratchObjType`](args) let `objTemp` = cast[ptr `scratchObjType`](args)
`functionStmtList` `functionStmtList`
proc `destroyName`(args: pointer) {.nimcall.} = proc `destroyName`(args: pointer) {.gcsafe, nimcall.} =
let `objTemp2` = cast[ptr `scratchObjType`](args) let `objTemp2` = cast[ptr `scratchObjType`](args)
`tempNode` `tempNode`