class Concurrent::Agent
def initialize(initial, opts = {})
(**opts)-
:copy_on_deref(String) -- call the given +Proc+ passing the internal value and -
:freeze_on_deref(String) -- call +#freeze+ before returning the data -
:dup_on_deref(String) -- call +#dup+ before returning the data -
:timeout(Fixnum) -- maximum number of seconds before an update is cancelled
Parameters:
-
opts(Hash) -- the options used to define the behavior at update and deref -
initial(Object) -- the initial value
def initialize(initial, opts = {}) @value = initial @rescuers = [] @validator = Proc.new { |result| true } @timeout = opts.fetch(:timeout, TIMEOUT).freeze @observers = CopyOnWriteObserverSet.new init_mutex set_deref_options(opts) end