Skip to content

Commit

Permalink
experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Aug 14, 2024
1 parent 8c7af51 commit 9b426d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions threading/channels.nim
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ proc channelSend(chan: ChannelRaw, data: pointer, size: int, blocking: static bo

when not blocking:
if chan.isFull(): return false

acquire(chan.lock)
if not tryAcquire(chan.lock): return false
else:
acquire(chan.lock)

# check for when another thread was faster to fill
when blocking:
Expand Down Expand Up @@ -221,8 +222,9 @@ proc channelReceive(chan: ChannelRaw, data: pointer, size: int, blocking: static

when not blocking:
if chan.isEmpty(): return false

acquire(chan.lock)
if not tryAcquire(chan.lock): return false
else:
acquire(chan.lock)

# check for when another thread was faster to empty
when blocking:
Expand Down

0 comments on commit 9b426d4

Please sign in to comment.