summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/system/channels.nim7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/system/channels.nim b/lib/system/channels.nim
index df46922e4..6e0c5b8c2 100644
--- a/lib/system/channels.nim
+++ b/lib/system/channels.nim
@@ -226,15 +226,16 @@ proc recv*[TMsg](c: var TChannel[TMsg]): TMsg =
   llRecv(q, addr(result), cast[PNimType](getTypeInfo(result)))

   releaseSys(q.lock)

 
-proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvaliable: bool,
+proc tryRecv*[TMsg](c: var TChannel[TMsg]): tuple[dataAvailable: bool,
                                                   msg: TMsg] =
   ## try to receives a message from the channel `c` if available. Otherwise
   ## it returns ``(false, default(msg))``.
   var q = cast[PRawChannel](addr(c))

-  if q.mask != ChannelDeadMask:

-    lockChannel(q):

+  if q.mask != ChannelDeadMask:
+    if tryAcquireSys(q.lock):

       llRecv(q, addr(result.msg), cast[PNimType](getTypeInfo(result.msg)))
       result.dataAvaliable = true

+      releaseSys(q.lock)

 

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

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