class Concurrent::JavaExchanger
def do_exchange(value, timeout)
-
(Object, CANCEL)
- the value exchanged by the other thread; {CANCEL} on timeout
def do_exchange(value, timeout) result = nil if timeout.nil? Synchronization::JRuby.sleep_interruptibly do result = @exchanger.exchange(value) end else Synchronization::JRuby.sleep_interruptibly do result = @exchanger.exchange(value, 1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS) end end result rescue java.util.concurrent.TimeoutException CANCEL end