summary refs log tree commit diff stats
path: root/lib/std
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-03-12 22:18:10 +0800
committerGitHub <noreply@github.com>2021-03-12 22:18:10 +0800
commit686bf3bfc6a492304e7f662a8da8fff436cba53e (patch)
tree26fb449e3815aa876a4d67fd3de9939c7e426985 /lib/std
parentc7e4e96aaf9d5148c4bc44a8c7dc4f462a8f2256 (diff)
downloadNim-686bf3bfc6a492304e7f662a8da8fff436cba53e.tar.gz
clarify the behavior of newChan
follow up the advice of `timothee`
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/channels.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/std/channels.nim b/lib/std/channels.nim
index a212af0d3..1b0844c48 100644
--- a/lib/std/channels.nim
+++ b/lib/std/channels.nim
@@ -506,5 +506,9 @@ func close*[T](c: Channel[T]): bool {.inline.} =
 func peek*[T](c: Channel[T]): int {.inline.} = peek(c.d)
 
 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!"
   result = Channel[T](d: allocChannel(sizeof(T), elements))