Skip to content

Commit 4f64c9f

Browse files
authored
add comments to spawn and pinnedSpawn (#19230)
`spawn` uses `nimSpawn3` internally and `pinnedSpawn` uses `nimSpawn4` internally. I comment it in order to help contributors get the gist of its functionality.
1 parent 99f8793 commit 4f64c9f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/pure/concurrency/threadpool.nim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,19 +448,21 @@ proc preferSpawn*(): bool =
448448
## <#spawnX.t>`_ instead.
449449
result = gSomeReady.counter > 0
450450

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

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

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

0 commit comments

Comments
 (0)