diff --git a/lib/monitor.rb b/lib/monitor.rb index 044219bcbb..c4ce06794a 100644 --- a/lib/monitor.rb +++ b/lib/monitor.rb @@ -87,6 +87,9 @@ # MonitorMixin module. # module MonitorMixin + EXCEPTION_NEVER = {Exception => :never}.freeze + EXCEPTION_IMMEDIATE = {Exception => :immediate}.freeze + # # FIXME: This isn't documented in Nutshell. # @@ -103,11 +106,11 @@ module MonitorMixin # even if no other thread doesn't signal. # def wait(timeout = nil) - Thread.handle_interrupt(Exception => :never) do + Thread.handle_interrupt(EXCEPTION_NEVER) do @monitor.__send__(:mon_check_owner) count = @monitor.__send__(:mon_exit_for_cond) begin - Thread.handle_interrupt(Exception => :immediate) do + Thread.handle_interrupt(EXCEPTION_IMMEDIATE) do @cond.wait(@monitor.instance_variable_get(:@mon_mutex), timeout) end return true @@ -227,11 +230,11 @@ module MonitorMixin def mon_synchronize # Prevent interrupt on handling interrupts; for example timeout errors # it may break locking state. - Thread.handle_interrupt(Exception => :never){ mon_enter } + Thread.handle_interrupt(EXCEPTION_NEVER){ mon_enter } begin yield ensure - Thread.handle_interrupt(Exception => :never){ mon_exit } + Thread.handle_interrupt(EXCEPTION_NEVER){ mon_exit } end end alias synchronize mon_synchronize