summary refs log tree commit diff stats
path: root/lib/system/channels.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-12-05 21:43:45 +0100
committerAraq <rumpf_a@web.de>2011-12-05 21:43:45 +0100
commitc6213c9774707b74662646dd0241e5b5e9c9313d (patch)
treee80f5ac0039f85c2ce32cb7e6ab2bab97f8a3b51 /lib/system/channels.nim
parent24e1d22ec9b6361a2e2ae607a1ed69cca51ac1b2 (diff)
downloadNim-c6213c9774707b74662646dd0241e5b5e9c9313d.tar.gz
fixes #71; sorry about the polling implementation
Diffstat (limited to 'lib/system/channels.nim')
-rwxr-xr-xlib/system/channels.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/system/channels.nim b/lib/system/channels.nim
index fe93d6840..47fa5b2e5 100755
--- a/lib/system/channels.nim
+++ b/lib/system/channels.nim
@@ -222,11 +222,14 @@ proc recv*[TMsg](c: var TChannel[TMsg]): TMsg =
   llRecv(q, addr(result), cast[PNimType](getTypeInfo(result)))

 

 proc peek*[TMsg](c: var TChannel[TMsg]): int =

-  ## returns the current number of messages in the channel `c`.

+  ## returns the current number of messages in the channel `c`. Returns -1

+  ## if the channel has been closed.

   var q = cast[PRawChannel](addr(c))

   if q.mask != ChannelDeadMask:

     lockChannel(q):

       result = q.count

+  else:

+    result = -1

 

 proc open*[TMsg](c: var TChannel[TMsg]) =

   ## opens a channel `c` for inter thread communication.