diff options
author | Zahary Karadjov <zahary@gmail.com> | 2011-12-11 11:26:50 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2011-12-11 11:26:50 +0200 |
commit | 67bc23bb60dda2895c47ae0747d106b6075c6a90 (patch) | |
tree | 4f4c66fad9ae5c42beefd31274091e295f31b639 /lib/system/channels.nim | |
parent | d171a8b36f10f42d35e64a7ddefa57376b419908 (diff) | |
parent | af792da0bbee6e9587b8aafafcd8f898f8fe9fd4 (diff) | |
download | Nim-67bc23bb60dda2895c47ae0747d106b6075c6a90.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod into upstream
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. |