diff options
author | Eric Wong <yahns-public@yhbt.net> | 2017-03-24 19:52:55 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2017-04-03 19:57:50 +0000 |
commit | 5024323bcfe81aa40fa0480c65aa876e8588987a (patch) | |
tree | beaec56db0b9819fe3cf90a851c9c4340fad2e39 | |
parent | 5bc5f36b5e5aef6340d94f8809122ac81fe466a2 (diff) | |
download | yahns-5024323bcfe81aa40fa0480c65aa876e8588987a.tar.gz |
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
-rw-r--r-- | lib/yahns/acceptor.rb | 6 | ||||
-rw-r--r-- | 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 @@ module Yahns::Acceptor # :nodoc: 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 @@ module Yahns::Acceptor # :nodoc: 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 @@ module Yahns::Acceptor # :nodoc: 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 5411c48..43caae6 100644 --- a/lib/yahns/server.rb +++ b/lib/yahns/server.rb @@ -450,7 +450,7 @@ class Yahns::Server # :nodoc: @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 |