Skip to content

Commit 74776f1

Browse files
author
Jaremy J. Creechley
committed
adding docs for newChan
1 parent f313015 commit 74776f1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

threading/channels.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,11 @@ when false:
402402
proc peek*[T](c: Chan[T]): int {.inline.} = peek(c.d)
403403

404404
proc newChan*[T](elements = 30, overwrite = false): Chan[T] =
405+
## create a new channel implemented using a ring buffer
406+
## with proper multi-threaded locking.
407+
##
408+
## `overwrite` sets up the channel to overwrite the oldest
409+
## data without blocking in `send` or `trySend`.
405410
assert elements >= 1, "Elements must be positive!"
406411
result = Chan[T](d: allocChannel(sizeof(T), elements))
407412
result.d.overwrite = overwrite

0 commit comments

Comments
 (0)