Module: Timeout::Sync
Do not use. This module is for internal use only.
| Relationships & Source Files | |
| Defined in: | lib/timeout.rb |
Class Method Summary
-
.synchronize(mutex, &block)
Calls mutex.synchronize(&block) but if that fails on CRuby due to being in a trap handler, run mutex.synchronize(&block) in a separate Thread instead.
Class Method Details
.synchronize(mutex, &block)
Calls mutex.synchronize(&block) but if that fails on CRuby due to being in a trap handler, run mutex.synchronize(&block) in a separate Thread instead.
# File 'lib/timeout.rb', line 188
def self.synchronize(mutex, &block) begin mutex.synchronize(&block) rescue ThreadError => e raise e unless e. == "can't be called from trap context" # Workaround CRuby issue https://bugs.ruby-lang.org/issues/19473 # which raises on Mutex#synchronize in trap handler. # It's expensive to create a Thread just for this, # but better than failing. Thread.new { mutex.synchronize(&block) }.join end end