Skip to content

Commit e03382d

Browse files
committed
Added untested Dereferenceable#value= method.
1 parent 8b33814 commit e03382d

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lib/concurrent/dereferenceable.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,25 @@ module Dereferenceable
2626
#
2727
# @return [Object] the current value of the object
2828
def value
29-
mutex.synchronize do
30-
apply_deref_options(@value)
31-
end
29+
mutex.synchronize{ apply_deref_options(@value) }
3230
end
3331
alias_method :deref, :value
3432

3533
protected
3634

35+
# Set the internal value of this object
36+
#
37+
# @param [Object] val the new value
38+
def value=(val)
39+
mutex.synchronize{ @value = val }
40+
end
41+
3742
# A mutex lock used for synchronizing thread-safe operations. Methods defined
3843
# by `Dereferenceable` are synchronized using the `Mutex` returned from this
3944
# method. Operations performed by the including class that operate on the
4045
# `@value` instance variable should be locked with this `Mutex`.
4146
#
4247
# @return [Mutex] the synchronization object
43-
#
44-
# @!visibility public
4548
def mutex
4649
@mutex
4750
end
@@ -51,8 +54,6 @@ def mutex
5154
# @note This method *must* be called from within the constructor of the including class.
5255
#
5356
# @see #mutex
54-
#
55-
# @!visibility public
5657
def init_mutex
5758
@mutex = Mutex.new
5859
end
@@ -69,8 +70,6 @@ def init_mutex
6970
# @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
7071
# @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
7172
# returning the value returned from the proc
72-
#
73-
# @!visibility public
7473
def set_deref_options(opts = {})
7574
mutex.synchronize do
7675
@dup_on_deref = opts[:dup_on_deref] || opts[:dup]

0 commit comments

Comments
 (0)