Skip to content

Commit

Permalink
add comments to spawn and pinnedSpawn (nim-lang#19230)
Browse files Browse the repository at this point in the history
`spawn` uses `nimSpawn3` internally and `pinnedSpawn` uses `nimSpawn4` internally. I comment it in order to help contributors get the gist of its functionality.
  • Loading branch information
ringabout authored and PMunch committed Mar 28, 2022
1 parent 042fdc2 commit 55a77f9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pure/concurrency/threadpool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -448,19 +448,21 @@ proc preferSpawn*(): bool =
## <#spawnX.t>`_ instead.
result = gSomeReady.counter > 0

proc spawn*(call: sink typed) {.magic: "Spawn".}
proc spawn*(call: sink typed) {.magic: "Spawn".} =
## Always spawns a new task, so that the `call` is never executed on
## the calling thread.
##
## `call` has to be a proc call `p(...)` where `p` is gcsafe and has a
## return type that is either `void` or compatible with `FlowVar[T]`.
discard "It uses `nimSpawn3` internally"

proc pinnedSpawn*(id: ThreadId; call: sink typed) {.magic: "Spawn".}
proc pinnedSpawn*(id: ThreadId; call: sink typed) {.magic: "Spawn".} =
## Always spawns a new task on the worker thread with `id`, so that
## the `call` is **always** executed on the thread.
##
## `call` has to be a proc call `p(...)` where `p` is gcsafe and has a
## return type that is either `void` or compatible with `FlowVar[T]`.
discard "It uses `nimSpawn4` internally"

template spawnX*(call) =
## Spawns a new task if a CPU core is ready, otherwise executes the
Expand Down

0 comments on commit 55a77f9

Please sign in to comment.