Support for it may be removed in future versions of Ruby(*),
and we actually do not need to waste time looping when
a instance variable will do.

(*) https://bugs.ruby-lang.org/issues/13245
---
 lib/yahns/acceptor.rb | 6 +++---
 lib/yahns/server.rb   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/yahns/acceptor.rb b/lib/yahns/acceptor.rb
index 7ab9f60..7340a1a 100644
--- a/lib/yahns/acceptor.rb
+++ b/lib/yahns/acceptor.rb
@@ -24,7 +24,7 @@ def ac_quit
       close
       return true
     end
-    @thrs.each { |t| t[:yahns_quit] = true }
+    @quit = true
     return true if __ac_quit_done?
 
     @thrs.each do
@@ -42,10 +42,10 @@ def ac_quit
   end
 
   def spawn_acceptor(nr, logger, client_class)
+    @quit = false
     @thrs = nr.times.map do
       Thread.new do
         queue = client_class.queue
-        t = Thread.current
         accept_flags = Kgio::SOCK_NONBLOCK | Kgio::SOCK_CLOEXEC
         qev_flags = client_class.superclass::QEV_FLAGS
         begin
@@ -64,7 +64,7 @@ def spawn_acceptor(nr, logger, client_class)
           sleep 1 # let other threads do some work
         rescue => e
           Yahns::Log.exception(logger, "accept loop", e)
-        end until t[:yahns_quit]
+        end until @quit
       end
     end
   end
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb
index 00e5f15..861b919 100644
--- a/lib/yahns/server.rb
+++ b/lib/yahns/server.rb
@@ -451,7 +451,7 @@ def quit_finish
     @queues.each(&:close).clear
 
     # we must not let quitter get GC-ed if we have any worker threads leftover
-    @wthr.each { |t| t[:yahns_quitter] = quitter }
+    @quitter = quitter
 
     quitter.close
   rescue => e
-- 
EW

--
unsubscribe: yahns-public+unsubscr...@yhbt.net
archive: https://yhbt.net/yahns-public/

Reply via email to