Skip to content

Commit a1dd621

Browse files
committed
open and close don't return bool
1 parent b83c5d2 commit a1dd621

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

tests/tchannels_simple.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ while true:
5555
worker2.joinThread()
5656

5757
# Clean up the channel.
58-
doAssert chan.close()
58+
chan.close()
5959
doAssert messages[^1] == "Another message"
6060
doAssert messages.len >= 2
6161

threading/channels.nim

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -312,25 +312,6 @@ proc recvMpmc(chan: ChannelRaw, data: pointer, size: int, nonBlocking: bool): bo
312312
signal(chan.notFullCond)
313313
result = true
314314

315-
proc channelCloseMpmc(chan: ChannelRaw): bool =
316-
# Unsynchronized
317-
318-
if chan.isClosed:
319-
# ChannelRaw already closed
320-
return false
321-
322-
store(chan.closed, true, moRelaxed)
323-
result = true
324-
325-
proc channelOpenMpmc(chan: ChannelRaw): bool =
326-
# Unsynchronized
327-
328-
if not chan.isClosed:
329-
# ChannelRaw already open
330-
return false
331-
332-
store(chan.closed, false, moRelaxed)
333-
result = true
334315

335316
# Public API
336317
# ----------------------------------------------------------------------------------
@@ -400,11 +381,11 @@ func recvIso*[T](c: Channel[T]): Isolated[T] {.inline.} =
400381
discard channelReceive(c, dst.addr, sizeof(dst), false)
401382
result = isolate(dst)
402383

403-
func open*[T](c: Channel[T]): bool {.inline.} =
404-
result = c.d.channelOpenMpmc()
384+
func open*[T](c: Channel[T]) {.inline.} =
385+
store(c.d.closed, false, moRelaxed)
405386

406-
func close*[T](c: Channel[T]): bool {.inline.} =
407-
result = c.d.channelCloseMpmc()
387+
func close*[T](c: Channel[T]) {.inline.} =
388+
store(c.d.closed, true, moRelaxed)
408389

409390
func peek*[T](c: Channel[T]): int {.inline.} = peek(c.d)
410391

0 commit comments

Comments
 (0)