clarify the behavior of newChan
follow up the advice of `timothee`
This commit is contained in:
parent
c7e4e96aaf
commit
686bf3bfc6
1 changed files with 4 additions and 0 deletions
|
|
@ -506,5 +506,9 @@ func close*[T](c: Channel[T]): bool {.inline.} =
|
||||||
func peek*[T](c: Channel[T]): int {.inline.} = peek(c.d)
|
func peek*[T](c: Channel[T]): int {.inline.} = peek(c.d)
|
||||||
|
|
||||||
proc newChannel*[T](elements = 30): Channel[T] =
|
proc newChannel*[T](elements = 30): Channel[T] =
|
||||||
|
## Returns a new `Channel`. `elements` should be positive.
|
||||||
|
## `elements` is used to specify whether a channel is buffered or not.
|
||||||
|
## If `elements` = 1, the channel is unbuffered. If `elements` > 1, the
|
||||||
|
## channel is buffered.
|
||||||
assert elements >= 1, "Elements must be positive!"
|
assert elements >= 1, "Elements must be positive!"
|
||||||
result = Channel[T](d: allocChannel(sizeof(T), elements))
|
result = Channel[T](d: allocChannel(sizeof(T), elements))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue