concurrent-ruby 1.0.5 → 1.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +42 -0
  3. data/Gemfile +39 -0
  4. data/{LICENSE.txt → LICENSE.md} +2 -0
  5. data/README.md +203 -105
  6. data/Rakefile +278 -0
  7. data/ext/concurrent-ruby/ConcurrentRubyService.java +17 -0
  8. data/ext/concurrent-ruby/com/concurrent_ruby/ext/AtomicReferenceLibrary.java +175 -0
  9. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JRubyMapBackendLibrary.java +248 -0
  10. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicBooleanLibrary.java +93 -0
  11. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaAtomicFixnumLibrary.java +113 -0
  12. data/ext/concurrent-ruby/com/concurrent_ruby/ext/JavaSemaphoreLibrary.java +159 -0
  13. data/ext/concurrent-ruby/com/concurrent_ruby/ext/SynchronizationLibrary.java +304 -0
  14. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMap.java +31 -0
  15. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/ConcurrentHashMapV8.java +3863 -0
  16. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/LongAdder.java +203 -0
  17. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/Striped64.java +342 -0
  18. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/ConcurrentHashMapV8.java +3800 -0
  19. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/LongAdder.java +204 -0
  20. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166e/nounsafe/Striped64.java +291 -0
  21. data/ext/concurrent-ruby/com/concurrent_ruby/ext/jsr166y/ThreadLocalRandom.java +199 -0
  22. data/lib/concurrent-ruby.rb +1 -0
  23. data/lib/concurrent.rb +24 -20
  24. data/lib/concurrent/agent.rb +7 -7
  25. data/lib/concurrent/array.rb +59 -32
  26. data/lib/concurrent/async.rb +4 -4
  27. data/lib/concurrent/atom.rb +9 -9
  28. data/lib/concurrent/atomic/atomic_boolean.rb +24 -20
  29. data/lib/concurrent/atomic/atomic_fixnum.rb +27 -23
  30. data/lib/concurrent/atomic/atomic_markable_reference.rb +164 -0
  31. data/lib/concurrent/atomic/atomic_reference.rb +176 -33
  32. data/lib/concurrent/atomic/count_down_latch.rb +6 -6
  33. data/lib/concurrent/atomic/cyclic_barrier.rb +1 -1
  34. data/lib/concurrent/atomic/event.rb +1 -1
  35. data/lib/concurrent/atomic/java_count_down_latch.rb +6 -5
  36. data/lib/concurrent/atomic/mutex_count_down_latch.rb +1 -0
  37. data/lib/concurrent/atomic/read_write_lock.rb +2 -1
  38. data/lib/concurrent/atomic/reentrant_read_write_lock.rb +3 -1
  39. data/lib/concurrent/atomic/semaphore.rb +8 -8
  40. data/lib/concurrent/atomic/thread_local_var.rb +7 -7
  41. data/lib/concurrent/atomic_reference/mutex_atomic.rb +3 -8
  42. data/lib/concurrent/atomic_reference/numeric_cas_wrapper.rb +1 -1
  43. data/lib/concurrent/atomics.rb +0 -43
  44. data/lib/concurrent/collection/lock_free_stack.rb +127 -0
  45. data/lib/concurrent/collection/map/atomic_reference_map_backend.rb +3 -3
  46. data/lib/concurrent/collection/map/non_concurrent_map_backend.rb +1 -2
  47. data/lib/concurrent/collection/non_concurrent_priority_queue.rb +29 -29
  48. data/lib/concurrent/concern/dereferenceable.rb +1 -1
  49. data/lib/concurrent/concern/logging.rb +6 -1
  50. data/lib/concurrent/concern/observable.rb +7 -7
  51. data/lib/concurrent/concurrent_ruby.jar +0 -0
  52. data/lib/concurrent/configuration.rb +1 -6
  53. data/lib/concurrent/constants.rb +1 -1
  54. data/lib/concurrent/dataflow.rb +2 -1
  55. data/lib/concurrent/delay.rb +9 -7
  56. data/lib/concurrent/exchanger.rb +13 -21
  57. data/lib/concurrent/executor/abstract_executor_service.rb +2 -2
  58. data/lib/concurrent/executor/cached_thread_pool.rb +1 -1
  59. data/lib/concurrent/executor/executor_service.rb +15 -15
  60. data/lib/concurrent/executor/fixed_thread_pool.rb +18 -18
  61. data/lib/concurrent/executor/java_thread_pool_executor.rb +10 -7
  62. data/lib/concurrent/executor/single_thread_executor.rb +2 -2
  63. data/lib/concurrent/executor/thread_pool_executor.rb +6 -6
  64. data/lib/concurrent/executor/timer_set.rb +1 -1
  65. data/lib/concurrent/future.rb +4 -1
  66. data/lib/concurrent/hash.rb +53 -30
  67. data/lib/concurrent/ivar.rb +5 -6
  68. data/lib/concurrent/map.rb +20 -25
  69. data/lib/concurrent/maybe.rb +1 -1
  70. data/lib/concurrent/mutable_struct.rb +15 -14
  71. data/lib/concurrent/mvar.rb +2 -2
  72. data/lib/concurrent/promise.rb +53 -21
  73. data/lib/concurrent/promises.rb +1938 -0
  74. data/lib/concurrent/re_include.rb +58 -0
  75. data/lib/concurrent/set.rb +66 -0
  76. data/lib/concurrent/settable_struct.rb +1 -0
  77. data/lib/concurrent/synchronization.rb +4 -5
  78. data/lib/concurrent/synchronization/abstract_lockable_object.rb +5 -5
  79. data/lib/concurrent/synchronization/abstract_struct.rb +6 -4
  80. data/lib/concurrent/synchronization/lockable_object.rb +6 -6
  81. data/lib/concurrent/synchronization/{mri_lockable_object.rb → mutex_lockable_object.rb} +19 -14
  82. data/lib/concurrent/synchronization/object.rb +8 -4
  83. data/lib/concurrent/synchronization/truffleruby_object.rb +46 -0
  84. data/lib/concurrent/synchronization/volatile.rb +11 -9
  85. data/lib/concurrent/thread_safe/util/data_structures.rb +55 -0
  86. data/lib/concurrent/thread_safe/util/striped64.rb +9 -4
  87. data/lib/concurrent/timer_task.rb +5 -2
  88. data/lib/concurrent/tuple.rb +1 -1
  89. data/lib/concurrent/tvar.rb +2 -2
  90. data/lib/concurrent/utility/at_exit.rb +1 -1
  91. data/lib/concurrent/utility/engine.rb +2 -2
  92. data/lib/concurrent/utility/monotonic_time.rb +3 -3
  93. data/lib/concurrent/utility/native_extension_loader.rb +31 -33
  94. data/lib/concurrent/utility/processor_counter.rb +0 -2
  95. data/lib/concurrent/version.rb +2 -2
  96. metadata +35 -21
  97. data/lib/concurrent/atomic_reference/concurrent_update_error.rb +0 -8
  98. data/lib/concurrent/atomic_reference/direct_update.rb +0 -81
  99. data/lib/concurrent/atomic_reference/jruby+truffle.rb +0 -2
  100. data/lib/concurrent/atomic_reference/jruby.rb +0 -16
  101. data/lib/concurrent/atomic_reference/rbx.rb +0 -22
  102. data/lib/concurrent/atomic_reference/ruby.rb +0 -32
  103. data/lib/concurrent/edge.rb +0 -26
  104. data/lib/concurrent/lazy_register.rb +0 -81
  105. data/lib/concurrent/synchronization/truffle_lockable_object.rb +0 -9
  106. data/lib/concurrent/synchronization/truffle_object.rb +0 -31
  107. data/lib/concurrent/thread_safe/util/array_hash_rbx.rb +0 -30
@@ -1,51 +1,194 @@
1
1
  require 'concurrent/synchronization'
2
2
  require 'concurrent/utility/engine'
3
- require 'concurrent/atomic_reference/concurrent_update_error'
4
- require 'concurrent/atomic_reference/mutex_atomic'
5
-
6
- begin
7
- # force fallback impl with FORCE_ATOMIC_FALLBACK=1
8
- if /[^0fF]/ =~ ENV['FORCE_ATOMIC_FALLBACK']
9
- ruby_engine = 'mutex_atomic'
10
- else
11
- ruby_engine = Concurrent.ruby_engine
12
- end
3
+ require 'concurrent/atomic_reference/numeric_cas_wrapper'
13
4
 
14
- require "concurrent/atomic_reference/#{ruby_engine}"
15
- rescue LoadError
16
- #warn 'Compiled extensions not installed, pure Ruby Atomic will be used.'
17
- end
5
+ module Concurrent
18
6
 
19
- if defined? Concurrent::JavaAtomicReference
7
+ # Define update methods that use direct paths
8
+ #
9
+ # @!visibility private
10
+ # @!macro internal_implementation_note
11
+ module AtomicDirectUpdate
20
12
 
21
- # @!macro atomic_reference
22
- class Concurrent::AtomicReference < Concurrent::JavaAtomicReference
23
- end
13
+ # @!macro atomic_reference_method_update
14
+ #
15
+ # Pass the current value to the given block, replacing it
16
+ # with the block's result. May retry if the value changes
17
+ # during the block's execution.
18
+ #
19
+ # @yield [Object] Calculate a new value for the atomic reference using
20
+ # given (old) value
21
+ # @yieldparam [Object] old_value the starting value of the atomic reference
22
+ # @return [Object] the new value
23
+ def update
24
+ true until compare_and_set(old_value = get, new_value = yield(old_value))
25
+ new_value
26
+ end
24
27
 
25
- elsif defined? Concurrent::RbxAtomicReference
28
+ # @!macro atomic_reference_method_try_update
29
+ #
30
+ # Pass the current value to the given block, replacing it
31
+ # with the block's result. Return nil if the update fails.
32
+ #
33
+ # @yield [Object] Calculate a new value for the atomic reference using
34
+ # given (old) value
35
+ # @yieldparam [Object] old_value the starting value of the atomic reference
36
+ # @note This method was altered to avoid raising an exception by default.
37
+ # Instead, this method now returns `nil` in case of failure. For more info,
38
+ # please see: https://github.com/ruby-concurrency/concurrent-ruby/pull/336
39
+ # @return [Object] the new value, or nil if update failed
40
+ def try_update
41
+ old_value = get
42
+ new_value = yield old_value
26
43
 
27
- # @!macro atomic_reference
28
- class Concurrent::AtomicReference < Concurrent::RbxAtomicReference
44
+ return unless compare_and_set old_value, new_value
45
+
46
+ new_value
47
+ end
48
+
49
+ # @!macro atomic_reference_method_try_update!
50
+ #
51
+ # Pass the current value to the given block, replacing it
52
+ # with the block's result. Raise an exception if the update
53
+ # fails.
54
+ #
55
+ # @yield [Object] Calculate a new value for the atomic reference using
56
+ # given (old) value
57
+ # @yieldparam [Object] old_value the starting value of the atomic reference
58
+ # @note This behavior mimics the behavior of the original
59
+ # `AtomicReference#try_update` API. The reason this was changed was to
60
+ # avoid raising exceptions (which are inherently slow) by default. For more
61
+ # info: https://github.com/ruby-concurrency/concurrent-ruby/pull/336
62
+ # @return [Object] the new value
63
+ # @raise [Concurrent::ConcurrentUpdateError] if the update fails
64
+ def try_update!
65
+ old_value = get
66
+ new_value = yield old_value
67
+ unless compare_and_set(old_value, new_value)
68
+ if $VERBOSE
69
+ raise ConcurrentUpdateError, "Update failed"
70
+ else
71
+ raise ConcurrentUpdateError, "Update failed", ConcurrentUpdateError::CONC_UP_ERR_BACKTRACE
72
+ end
73
+ end
74
+ new_value
75
+ end
29
76
  end
30
77
 
31
- elsif defined? Concurrent::CAtomicReference
78
+ require 'concurrent/atomic_reference/mutex_atomic'
32
79
 
33
80
  # @!macro atomic_reference
34
- class Concurrent::AtomicReference < Concurrent::CAtomicReference
81
+ #
82
+ # An object reference that may be updated atomically. All read and write
83
+ # operations have java volatile semantic.
84
+ #
85
+ # @!macro thread_safe_variable_comparison
86
+ #
87
+ # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicReference.html
88
+ # @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/package-summary.html
89
+ #
90
+ # @!method initialize(value = nil)
91
+ # @!macro atomic_reference_method_initialize
92
+ # @param [Object] value The initial value.
93
+ #
94
+ # @!method get
95
+ # @!macro atomic_reference_method_get
96
+ # Gets the current value.
97
+ # @return [Object] the current value
98
+ #
99
+ # @!method set(new_value)
100
+ # @!macro atomic_reference_method_set
101
+ # Sets to the given value.
102
+ # @param [Object] new_value the new value
103
+ # @return [Object] the new value
104
+ #
105
+ # @!method get_and_set(new_value)
106
+ # @!macro atomic_reference_method_get_and_set
107
+ # Atomically sets to the given value and returns the old value.
108
+ # @param [Object] new_value the new value
109
+ # @return [Object] the old value
110
+ #
111
+ # @!method compare_and_set(old_value, new_value)
112
+ # @!macro atomic_reference_method_compare_and_set
113
+ #
114
+ # Atomically sets the value to the given updated value if
115
+ # the current value == the expected value.
116
+ #
117
+ # @param [Object] old_value the expected value
118
+ # @param [Object] new_value the new value
119
+ #
120
+ # @return [Boolean] `true` if successful. A `false` return indicates
121
+ # that the actual value was not equal to the expected value.
122
+ #
123
+ # @!method update
124
+ # @!macro atomic_reference_method_update
125
+ #
126
+ # @!method try_update
127
+ # @!macro atomic_reference_method_try_update
128
+ #
129
+ # @!method try_update!
130
+ # @!macro atomic_reference_method_try_update!
131
+
132
+
133
+ # @!macro internal_implementation_note
134
+ class ConcurrentUpdateError < ThreadError
135
+ # frozen pre-allocated backtrace to speed ConcurrentUpdateError
136
+ CONC_UP_ERR_BACKTRACE = ['backtrace elided; set verbose to enable'].freeze
35
137
  end
36
138
 
37
- else
139
+ # @!macro internal_implementation_note
140
+ AtomicReferenceImplementation = case
141
+ when Concurrent.on_cruby? && Concurrent.c_extensions_loaded?
142
+ # @!visibility private
143
+ # @!macro internal_implementation_note
144
+ class CAtomicReference
145
+ include AtomicDirectUpdate
146
+ include AtomicNumericCompareAndSetWrapper
147
+ alias_method :compare_and_swap, :compare_and_set
148
+ end
149
+ CAtomicReference
150
+ when Concurrent.on_jruby?
151
+ # @!visibility private
152
+ # @!macro internal_implementation_note
153
+ class JavaAtomicReference
154
+ include AtomicDirectUpdate
155
+ end
156
+ JavaAtomicReference
157
+ when Concurrent.on_truffleruby?
158
+ class TruffleRubyAtomicReference < Truffle::AtomicReference
159
+ include AtomicDirectUpdate
160
+ alias_method :compare_and_swap, :compare_and_set
161
+ alias_method :swap, :get_and_set
162
+ end
163
+ when Concurrent.on_rbx?
164
+ # @note Extends `Rubinius::AtomicReference` version adding aliases
165
+ # and numeric logic.
166
+ #
167
+ # @!visibility private
168
+ # @!macro internal_implementation_note
169
+ class RbxAtomicReference < Rubinius::AtomicReference
170
+ alias_method :_compare_and_set, :compare_and_set
171
+ include AtomicDirectUpdate
172
+ include AtomicNumericCompareAndSetWrapper
173
+ alias_method :value, :get
174
+ alias_method :value=, :set
175
+ alias_method :swap, :get_and_set
176
+ alias_method :compare_and_swap, :compare_and_set
177
+ end
178
+ RbxAtomicReference
179
+ else
180
+ MutexAtomicReference
181
+ end
182
+ private_constant :AtomicReferenceImplementation
38
183
 
39
184
  # @!macro atomic_reference
40
- class Concurrent::AtomicReference < Concurrent::MutexAtomicReference
41
- end
42
- end
185
+ class AtomicReference < AtomicReferenceImplementation
43
186
 
44
- class Concurrent::AtomicReference
45
- # @return [String] Short string representation.
46
- def to_s
47
- format '<#%s:0x%x value:%s>', self.class, object_id << 1, get
48
- end
187
+ # @return [String] Short string representation.
188
+ def to_s
189
+ format '%s value:%s>', super[0..-2], get
190
+ end
49
191
 
50
- alias_method :inspect, :to_s
192
+ alias_method :inspect, :to_s
193
+ end
51
194
  end
@@ -6,7 +6,7 @@ module Concurrent
6
6
 
7
7
  ###################################################################
8
8
 
9
- # @!macro [new] count_down_latch_method_initialize
9
+ # @!macro count_down_latch_method_initialize
10
10
  #
11
11
  # Create a new `CountDownLatch` with the initial `count`.
12
12
  #
@@ -14,7 +14,7 @@ module Concurrent
14
14
  #
15
15
  # @raise [ArgumentError] if `count` is not an integer or is less than zero
16
16
 
17
- # @!macro [new] count_down_latch_method_wait
17
+ # @!macro count_down_latch_method_wait
18
18
  #
19
19
  # Block on the latch until the counter reaches zero or until `timeout` is reached.
20
20
  #
@@ -22,12 +22,12 @@ module Concurrent
22
22
  # to block indefinitely
23
23
  # @return [Boolean] `true` if the `count` reaches zero else false on `timeout`
24
24
 
25
- # @!macro [new] count_down_latch_method_count_down
25
+ # @!macro count_down_latch_method_count_down
26
26
  #
27
27
  # Signal the latch to decrement the counter. Will signal all blocked threads when
28
28
  # the `count` reaches zero.
29
29
 
30
- # @!macro [attach] count_down_latch_method_count
30
+ # @!macro count_down_latch_method_count
31
31
  #
32
32
  # The current value of the counter.
33
33
  #
@@ -35,7 +35,7 @@ module Concurrent
35
35
 
36
36
  ###################################################################
37
37
 
38
- # @!macro [new] count_down_latch_public_api
38
+ # @!macro count_down_latch_public_api
39
39
  #
40
40
  # @!method initialize(count = 1)
41
41
  # @!macro count_down_latch_method_initialize
@@ -61,7 +61,7 @@ module Concurrent
61
61
  end
62
62
  private_constant :CountDownLatchImplementation
63
63
 
64
- # @!macro [attach] count_down_latch
64
+ # @!macro count_down_latch
65
65
  #
66
66
  # A synchronization object that allows one thread to wait on multiple other threads.
67
67
  # The thread that will wait creates a `CountDownLatch` and sets the initial value
@@ -23,7 +23,7 @@ module Concurrent
23
23
  # # use main as well
24
24
  # process.call 2
25
25
  #
26
- # # here we can be sure that all jobs are processed
26
+ # # here we can be sure that all jobs are processed
27
27
  class CyclicBarrier < Synchronization::LockableObject
28
28
 
29
29
  # @!visibility private
@@ -32,7 +32,7 @@ module Concurrent
32
32
  # # prints:
33
33
  # # t2 calling set
34
34
  # # t1 is waiting
35
- # # event ocurred
35
+ # # event occurred
36
36
  class Event < Synchronization::LockableObject
37
37
 
38
38
  # Creates a new `Event` in the unset state. Threads calling `#wait` on the
@@ -9,19 +9,20 @@ if Concurrent.on_jruby?
9
9
 
10
10
  # @!macro count_down_latch_method_initialize
11
11
  def initialize(count = 1)
12
- unless count.is_a?(Fixnum) && count >= 0
13
- raise ArgumentError.new('count must be in integer greater than or equal zero')
14
- end
12
+ Utility::NativeInteger.ensure_integer_and_bounds(count)
13
+ Utility::NativeInteger.ensure_positive(count)
15
14
  @latch = java.util.concurrent.CountDownLatch.new(count)
16
15
  end
17
16
 
18
17
  # @!macro count_down_latch_method_wait
19
18
  def wait(timeout = nil)
20
19
  if timeout.nil?
21
- @latch.await
20
+ Synchronization::JRuby.sleep_interruptibly { @latch.await }
22
21
  true
23
22
  else
24
- @latch.await(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)
23
+ Synchronization::JRuby.sleep_interruptibly do
24
+ @latch.await(1000 * timeout, java.util.concurrent.TimeUnit::MILLISECONDS)
25
+ end
25
26
  end
26
27
  end
27
28
 
@@ -1,4 +1,5 @@
1
1
  require 'concurrent/synchronization'
2
+ require 'concurrent/utility/native_integer'
2
3
 
3
4
  module Concurrent
4
5
 
@@ -193,7 +193,8 @@ module Concurrent
193
193
  #
194
194
  # @return [Boolean] true if the lock is successfully released
195
195
  def release_write_lock
196
- c = @Counter.update { |counter| counter-RUNNING_WRITER }
196
+ return true unless running_writer?
197
+ c = @Counter.update { |counter| counter - RUNNING_WRITER }
197
198
  @ReadLock.broadcast
198
199
  @WriteLock.signal if waiting_writers(c) > 0
199
200
  true
@@ -21,7 +21,9 @@ module Concurrent
21
21
  # also acquire a read lock OR a write lock more than once. Only when the read (or
22
22
  # write) lock is released as many times as it was acquired, will the thread
23
23
  # actually let it go, allowing other threads which might have been waiting
24
- # to proceed.
24
+ # to proceed. Therefore the lock can be upgraded by first acquiring
25
+ # read lock and then write lock and that the lock can be downgraded by first
26
+ # having both read and write lock a releasing just the write lock.
25
27
  #
26
28
  # If both read and write locks are acquired by the same thread, it is not strictly
27
29
  # necessary to release them in the same order they were acquired. In other words,
@@ -5,7 +5,7 @@ module Concurrent
5
5
 
6
6
  ###################################################################
7
7
 
8
- # @!macro [new] semaphore_method_initialize
8
+ # @!macro semaphore_method_initialize
9
9
  #
10
10
  # Create a new `Semaphore` with the initial `count`.
11
11
  #
@@ -13,7 +13,7 @@ module Concurrent
13
13
  #
14
14
  # @raise [ArgumentError] if `count` is not an integer or is less than zero
15
15
 
16
- # @!macro [new] semaphore_method_acquire
16
+ # @!macro semaphore_method_acquire
17
17
  #
18
18
  # Acquires the given number of permits from this semaphore,
19
19
  # blocking until all are available.
@@ -25,19 +25,19 @@ module Concurrent
25
25
  #
26
26
  # @return [nil]
27
27
 
28
- # @!macro [new] semaphore_method_available_permits
28
+ # @!macro semaphore_method_available_permits
29
29
  #
30
30
  # Returns the current number of permits available in this semaphore.
31
31
  #
32
32
  # @return [Integer]
33
33
 
34
- # @!macro [new] semaphore_method_drain_permits
34
+ # @!macro semaphore_method_drain_permits
35
35
  #
36
36
  # Acquires and returns all permits that are immediately available.
37
37
  #
38
38
  # @return [Integer]
39
39
 
40
- # @!macro [new] semaphore_method_try_acquire
40
+ # @!macro semaphore_method_try_acquire
41
41
  #
42
42
  # Acquires the given number of permits from this semaphore,
43
43
  # only if all are available at the time of invocation or within
@@ -54,7 +54,7 @@ module Concurrent
54
54
  # @return [Boolean] `false` if no permits are available, `true` when
55
55
  # acquired a permit
56
56
 
57
- # @!macro [new] semaphore_method_release
57
+ # @!macro semaphore_method_release
58
58
  #
59
59
  # Releases the given number of permits, returning them to the semaphore.
60
60
  #
@@ -66,7 +66,7 @@ module Concurrent
66
66
 
67
67
  ###################################################################
68
68
 
69
- # @!macro [new] semaphore_public_api
69
+ # @!macro semaphore_public_api
70
70
  #
71
71
  # @!method initialize(count)
72
72
  # @!macro semaphore_method_initialize
@@ -98,7 +98,7 @@ module Concurrent
98
98
  end
99
99
  private_constant :SemaphoreImplementation
100
100
 
101
- # @!macro [attach] semaphore
101
+ # @!macro semaphore
102
102
  #
103
103
  # A counting semaphore. Conceptually, a semaphore maintains a set of
104
104
  # permits. Each {#acquire} blocks if necessary until a permit is
@@ -6,7 +6,7 @@ module Concurrent
6
6
 
7
7
  ###################################################################
8
8
 
9
- # @!macro [new] thread_local_var_method_initialize
9
+ # @!macro thread_local_var_method_initialize
10
10
  #
11
11
  # Creates a thread local variable.
12
12
  #
@@ -14,20 +14,20 @@ module Concurrent
14
14
  # @param [Proc] default_block Optional block that gets called to obtain the
15
15
  # default value for each thread
16
16
 
17
- # @!macro [new] thread_local_var_method_get
17
+ # @!macro thread_local_var_method_get
18
18
  #
19
19
  # Returns the value in the current thread's copy of this thread-local variable.
20
20
  #
21
21
  # @return [Object] the current value
22
22
 
23
- # @!macro [new] thread_local_var_method_set
23
+ # @!macro thread_local_var_method_set
24
24
  #
25
25
  # Sets the current thread's copy of this thread-local variable to the specified value.
26
26
  #
27
27
  # @param [Object] value the value to set
28
28
  # @return [Object] the new value
29
29
 
30
- # @!macro [new] thread_local_var_method_bind
30
+ # @!macro thread_local_var_method_bind
31
31
  #
32
32
  # Bind the given value to thread local storage during
33
33
  # execution of the given block.
@@ -39,9 +39,9 @@ module Concurrent
39
39
 
40
40
  ###################################################################
41
41
 
42
- # @!macro [new] thread_local_var_public_api
42
+ # @!macro thread_local_var_public_api
43
43
  #
44
- # @!method initialize(default = nil)
44
+ # @!method initialize(default = nil, &default_block)
45
45
  # @!macro thread_local_var_method_initialize
46
46
  #
47
47
  # @!method value
@@ -65,7 +65,7 @@ module Concurrent
65
65
  end
66
66
  private_constant :ThreadLocalVarImplementation
67
67
 
68
- # @!macro [attach] thread_local_var
68
+ # @!macro thread_local_var
69
69
  #
70
70
  # A `ThreadLocalVar` is a variable where the value is different for each thread.
71
71
  # Each variable may have a default value, but when you modify the variable only