fix: exit condition handling

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
This commit is contained in:
Christopher Arndt 2023-06-06 04:26:54 +02:00
parent 227ab3f45d
commit f78bb963fb
1 changed files with 4 additions and 1 deletions

View File

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