From f78bb963fbe86d17b4b057ef83d335c6173489ea Mon Sep 17 00:00:00 2001 From: Christopher Arndt Date: Tue, 6 Jun 2023 04:26:54 +0200 Subject: [PATCH] fix: exit condition handling Signed-off-by: Christopher Arndt --- examples/jacket_midi_print_ringbuffer.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/jacket_midi_print_ringbuffer.nim b/examples/jacket_midi_print_ringbuffer.nim index f0e7342..15195d5 100644 --- a/examples/jacket_midi_print_ringbuffer.nim +++ b/examples/jacket_midi_print_ringbuffer.nim @@ -67,7 +67,7 @@ proc midiEventPrinterProc() {.thread.} = dataReadyLock.acquire() - while not exitLoop: + while true: while not exitLoop and ringbufferReadSpace(rb) >= 4: var read = cast[int](ringbufferRead(rb, cast[cstring](recvBuf.addr), 4)) @@ -78,6 +78,9 @@ proc midiEventPrinterProc() {.thread.} = stdout.write("\n") stdout.flushFile() + if exitLoop: + break + dataReady.wait(dataReadyLock) dataReadyLock.release()