fixes #71; sorry about the polling implementation

This commit is contained in:
Araq 2011-12-05 21:43:45 +01:00
commit c6213c9774
6 changed files with 62 additions and 12 deletions

View file

@ -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.