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()