diff options
author | Araq <rumpf_a@web.de> | 2011-12-05 21:43:45 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-12-05 21:43:45 +0100 |
commit | c6213c9774707b74662646dd0241e5b5e9c9313d (patch) | |
tree | e80f5ac0039f85c2ce32cb7e6ab2bab97f8a3b51 /lib/system/channels.nim | |
parent | 24e1d22ec9b6361a2e2ae607a1ed69cca51ac1b2 (diff) | |
download | Nim-c6213c9774707b74662646dd0241e5b5e9c9313d.tar.gz |
fixes #71; sorry about the polling implementation
Diffstat (limited to 'lib/system/channels.nim')
-rwxr-xr-x | lib/system/channels.nim | 5 |
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. |