@@ -26,40 +26,7 @@ module Concurrent
2626 # when the values they depend on are ready you want `dataflow`. `IVar` is
2727 # generally a low-level primitive.
2828 #
29- # @!macro [attach] copy_options
30- # ## Copy Options
31- #
32- # Object references in Ruby are mutable. This can lead to serious
33- # problems when the {#value} of an object is a mutable reference. Which
34- # is always the case unless the value is a `Fixnum`, `Symbol`, or similar
35- # "primative" data type. Each instance can be configured with a few
36- # options that can help protect the program from potentially dangerous
37- # operations. Each of these options can be optionally set when the oject
38- # instance is created:
39- #
40- # * `:dup_on_deref` When true the object will call the `#dup` method on
41- # the `value` object every time the `#value` methid is called
42- # (default: false)
43- # * `:freeze_on_deref` When true the object will call the `#freeze`
44- # method on the `value` object every time the `#value` method is called
45- # (default: false)
46- # * `:copy_on_deref` When given a `Proc` object the `Proc` will be run
47- # every time the `#value` method is called. The `Proc` will be given
48- # the current `value` as its only argument and the result returned by
49- # the block will be the return value of the `#value` call. When `nil`
50- # this option will be ignored (default: nil)
51- #
52- # When multiple deref options are set the order of operations is strictly defined.
53- # The order of deref operations is:
54- # * `:copy_on_deref`
55- # * `:dup_on_deref`
56- # * `:freeze_on_deref`
57- #
58- # Because of this ordering there is no need to `#freeze` an object created by a
59- # provided `:copy_on_deref` block. Simply set `:freeze_on_deref` to `true`.
60- # Setting both `:dup_on_deref` to `true` and `:freeze_on_deref` to `true` is
61- # as close to the behavior of a "pure" functional language (like Erlang, Clojure,
62- # or Haskell) as we are likely to get in Ruby.
29+ # @!macro copy_options
6330 #
6431 # ## Examples
6532 #
@@ -91,14 +58,7 @@ class IVar < Synchronization::Object
9158 # @param [Object] value the initial value
9259 # @param [Hash] opts the options to create a message with
9360 #
94- # @!macro [attach] deref_options
95- # @option opts [Boolean] :dup_on_deref (false) Call `#dup` before
96- # returning the data from {#value}
97- # @option opts [Boolean] :freeze_on_deref (false) Call `#freeze` before
98- # returning the data from {#value}
99- # @option opts [Proc] :copy_on_deref (nil) When calling the {#value}
100- # method, call the given proc passing the internal value as the sole
101- # argument then return the new value returned from the proc.
61+ # @!macro deref_options
10262 def initialize ( value = NO_VALUE , opts = { } , &block )
10363 if value != NO_VALUE && block_given?
10464 raise ArgumentError . new ( 'provide only a value or a block' )
0 commit comments