Skip to content

Commit b828b4c

Browse files
committed
Fixed yardoc
1 parent 88606fe commit b828b4c

File tree

4 files changed

+52
-50
lines changed

4 files changed

+52
-50
lines changed

lib/concurrent/actor/behaviour.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ module Actor
1717
#
1818
# > {include:Actor::Behaviour::Pausing}
1919
#
20-
# - {Behaviour::Supervised}:
20+
# - {Behaviour::Supervising}:
2121
#
22-
# > {include:Actor::Behaviour::Supervised}
22+
# > {include:Actor::Behaviour::Supervising}
2323
#
2424
# - {Behaviour::Supervising}:
2525
#

lib/concurrent/atom.rb

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,40 @@ module Concurrent
1818
# new value to the result of running the given block if and only if that
1919
# value validates.
2020
#
21-
# @!macro copy_options
21+
# @!macro [attach] copy_options
22+
# ## Copy Options
23+
#
24+
# Object references in Ruby are mutable. This can lead to serious
25+
# problems when the {#value} of an object is a mutable reference. Which
26+
# is always the case unless the value is a `Fixnum`, `Symbol`, or similar
27+
# "primative" data type. Each instance can be configured with a few
28+
# options that can help protect the program from potentially dangerous
29+
# operations. Each of these options can be optionally set when the oject
30+
# instance is created:
31+
#
32+
# * `:dup_on_deref` When true the object will call the `#dup` method on
33+
# the `value` object every time the `#value` methid is called
34+
# (default: false)
35+
# * `:freeze_on_deref` When true the object will call the `#freeze`
36+
# method on the `value` object every time the `#value` method is called
37+
# (default: false)
38+
# * `:copy_on_deref` When given a `Proc` object the `Proc` will be run
39+
# every time the `#value` method is called. The `Proc` will be given
40+
# the current `value` as its only argument and the result returned by
41+
# the block will be the return value of the `#value` call. When `nil`
42+
# this option will be ignored (default: nil)
43+
#
44+
# When multiple deref options are set the order of operations is strictly defined.
45+
# The order of deref operations is:
46+
# * `:copy_on_deref`
47+
# * `:dup_on_deref`
48+
# * `:freeze_on_deref`
49+
#
50+
# Because of this ordering there is no need to `#freeze` an object created by a
51+
# provided `:copy_on_deref` block. Simply set `:freeze_on_deref` to `true`.
52+
# Setting both `:dup_on_deref` to `true` and `:freeze_on_deref` to `true` is
53+
# as close to the behavior of a "pure" functional language (like Erlang, Clojure,
54+
# or Haskell) as we are likely to get in Ruby.
2255
#
2356
# @see http://clojure.org/atoms Clojure Atoms
2457
class Atom < Synchronization::Object
@@ -33,7 +66,14 @@ class Atom < Synchronization::Object
3366
# intended new value. The validator will return true if the new value
3467
# is acceptable else return false (preferrably) or raise an exception.
3568
#
36-
# @!macro deref_options
69+
# @!macro [attach] deref_options
70+
# @option opts [Boolean] :dup_on_deref (false) Call `#dup` before
71+
# returning the data from {#value}
72+
# @option opts [Boolean] :freeze_on_deref (false) Call `#freeze` before
73+
# returning the data from {#value}
74+
# @option opts [Proc] :copy_on_deref (nil) When calling the {#value}
75+
# method, call the given proc passing the internal value as the sole
76+
# argument then return the new value returned from the proc.
3777
#
3878
# @raise [ArgumentError] if the validator is not a `Proc` (when given)
3979
def initialize(value, opts = {})

lib/concurrent/ivar.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ module Concurrent
2727
# when the values they depend on are ready you want `dataflow`. `IVar` is
2828
# generally a low-level primitive.
2929
#
30-
# @!macro copy_options
31-
#
3230
# ## Examples
3331
#
3432
# Create, set and get an `IVar`
@@ -58,8 +56,12 @@ class IVar < Synchronization::Object
5856
#
5957
# @param [Object] value the initial value
6058
# @param [Hash] opts the options to create a message with
61-
#
62-
# @!macro deref_options
59+
# @option opts [String] :dup_on_deref (false) call `#dup` before returning
60+
# the data
61+
# @option opts [String] :freeze_on_deref (false) call `#freeze` before
62+
# returning the data
63+
# @option opts [String] :copy_on_deref (nil) call the given `Proc` passing
64+
# the internal value and returning the value returned from the proc
6365
def initialize(value = NO_VALUE, opts = {}, &block)
6466
if value != NO_VALUE && block_given?
6567
raise ArgumentError.new('provide only a value or a block')

lib/concurrent/mvar.rb

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,7 @@ module Concurrent
2424
# Note that unlike the original Haskell paper, our `#take` is blocking. This is how
2525
# Haskell and Scala do it today.
2626
#
27-
# @!macro [attach] copy_options
28-
# ## Copy Options
29-
#
30-
# Object references in Ruby are mutable. This can lead to serious
31-
# problems when the {#value} of an object is a mutable reference. Which
32-
# is always the case unless the value is a `Fixnum`, `Symbol`, or similar
33-
# "primative" data type. Each instance can be configured with a few
34-
# options that can help protect the program from potentially dangerous
35-
# operations. Each of these options can be optionally set when the oject
36-
# instance is created:
37-
#
38-
# * `:dup_on_deref` When true the object will call the `#dup` method on
39-
# the `value` object every time the `#value` methid is called
40-
# (default: false)
41-
# * `:freeze_on_deref` When true the object will call the `#freeze`
42-
# method on the `value` object every time the `#value` method is called
43-
# (default: false)
44-
# * `:copy_on_deref` When given a `Proc` object the `Proc` will be run
45-
# every time the `#value` method is called. The `Proc` will be given
46-
# the current `value` as its only argument and the result returned by
47-
# the block will be the return value of the `#value` call. When `nil`
48-
# this option will be ignored (default: nil)
49-
#
50-
# When multiple deref options are set the order of operations is strictly defined.
51-
# The order of deref operations is:
52-
# * `:copy_on_deref`
53-
# * `:dup_on_deref`
54-
# * `:freeze_on_deref`
55-
#
56-
# Because of this ordering there is no need to `#freeze` an object created by a
57-
# provided `:copy_on_deref` block. Simply set `:freeze_on_deref` to `true`.
58-
# Setting both `:dup_on_deref` to `true` and `:freeze_on_deref` to `true` is
59-
# as close to the behavior of a "pure" functional language (like Erlang, Clojure,
60-
# or Haskell) as we are likely to get in Ruby.
27+
# @!macro copy_options
6128
#
6229
# ## See Also
6330
#
@@ -82,14 +49,7 @@ class MVar
8249
#
8350
# @param [Hash] opts the options controlling how the future will be processed
8451
#
85-
# @!macro [attach] deref_options
86-
# @option opts [Boolean] :dup_on_deref (false) Call `#dup` before
87-
# returning the data from {#value}
88-
# @option opts [Boolean] :freeze_on_deref (false) Call `#freeze` before
89-
# returning the data from {#value}
90-
# @option opts [Proc] :copy_on_deref (nil) When calling the {#value}
91-
# method, call the given proc passing the internal value as the sole
92-
# argument then return the new value returned from the proc.
52+
# @!macro deref_options
9353
def initialize(value = EMPTY, opts = {})
9454
@value = value
9555
@mutex = Mutex.new

0 commit comments

Comments
 (0)