From a754e3b9ea65ad2ed07e951f669d81232a662b1b Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 3 Aug 2023 11:04:13 +0100 Subject: [PATCH] move @running into init_producer --- lib/voicemeeter/worker.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/voicemeeter/worker.rb b/lib/voicemeeter/worker.rb index f9f9210..58d8b7b 100644 --- a/lib/voicemeeter/worker.rb +++ b/lib/voicemeeter/worker.rb @@ -7,7 +7,9 @@ module Voicemeeter include Logging def init_producer(que) + @running = true Thread.new do + Thread.current.name = "producer" while @running que << :pdirty if event.pdirty que << :mdirty if event.mdirty @@ -15,7 +17,7 @@ module Voicemeeter que << :ldirty if event.ldirty sleep(@ratelimit) end - logger.debug "closing producer thread" + logger.debug "closing #{Thread.current.name} thread" que << :stop end end @@ -25,12 +27,12 @@ module Voicemeeter @cache[:strip_level], @cache[:bus_level] = _get_levels @cache[:strip_comp] = Array.new(kind.num_strip_levels, false) @cache[:bus_comp] = Array.new(kind.num_bus_levels, false) - @running = true Thread.new do + Thread.current.name = "worker" loop do e_from_que = @que.pop if e_from_que == :stop - logger.debug "closing worker thread" + logger.debug "closing #{Thread.current.name} thread" break end trigger :on_pdirty if e_from_que == :pdirty && pdirty?