class Concurrent::AbstractExchanger
@!visibility private
def do_exchange(value, timeout)
-
(Object, CANCEL)- the value exchanged by the other thread; {CANCEL} on timeout
def do_exchange(value, timeout) raise NotImplementedError end
def exchange(value, timeout = nil)
-
(Object)- the value exchanged by the other thread or `nil` on timeout
Parameters:
-
timeout(Numeric, nil) -- in seconds, `nil` blocks indefinitely -
value(Object) -- the value to exchange with another thread
def exchange(value, timeout = nil) (value = do_exchange(value, timeout)) == CANCEL ? nil : value end
def exchange!(value, timeout = nil)
-
(Concurrent::TimeoutError)- on timeout
Returns:
-
(Object)- the value exchanged by the other thread
def exchange!(value, timeout = nil) if (value = do_exchange(value, timeout)) == CANCEL raise Concurrent::TimeoutError else value end end
def initialize
def initialize super end
def try_exchange(value, timeout = nil)
-
(Concurrent::Maybe)- on success a `Just` maybe will be returned with
def try_exchange(value, timeout = nil) if (value = do_exchange(value, timeout)) == CANCEL Concurrent::Maybe.nothing(Concurrent::TimeoutError) else Concurrent::Maybe.just(value) end end