Skip to content

Commit 629d07a

Browse files
committed
Remove auto call to ns_initialize
1 parent 4b5cb7c commit 629d07a

27 files changed

+95
-48
lines changed

ext/com/concurrent_ruby/ext/SynchronizationLibrary.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ public JavaObject(Ruby runtime, RubyClass metaClass) {
4949
super(runtime, metaClass);
5050
}
5151

52-
@JRubyMethod(rest = true)
53-
public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block) {
54-
synchronized (this) {
55-
return callMethod(context, "ns_initialize", args, block);
56-
}
52+
@JRubyMethod
53+
public IRubyObject initialize(ThreadContext context) {
54+
return this;
5755
}
5856

5957
@JRubyMethod(name = "synchronize", visibility = Visibility.PROTECTED)

lib/concurrent/actor/core.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class Core < Synchronization::Object
4949
# any logging system
5050
# @param [Proc] block for class instantiation
5151
def initialize(opts = {}, &block)
52-
super
52+
super(&nil)
53+
synchronize { ns_initialize(opts, &block) }
5354
end
5455

5556
# @return [Reference, nil] of parent actor

lib/concurrent/at_exit.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ module Concurrent
88
class AtExitImplementation < Synchronization::Object
99
include Logging
1010

11+
def initialize(*args)
12+
super()
13+
synchronize { ns_initialize *args }
14+
end
15+
1116
# Add a handler to be run at `Kernel#at_exit`
1217
# @param [Object] handler_id optionally provide an id, if allready present, handler is replaced
1318
# @yield the handler

lib/concurrent/atomic/atomic_boolean.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class MutexAtomicBoolean < Synchronization::Object
3030
#
3131
# @param [Boolean] initial the initial value
3232
def initialize(initial = false)
33-
super(initial)
33+
super()
34+
synchronize { ns_initialize(initial) }
3435
end
3536

3637
# @!macro [attach] atomic_boolean_method_value_get

lib/concurrent/atomic/atomic_fixnum.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class MutexAtomicFixnum < Synchronization::Object
3535
# @param [Fixnum] initial the initial value
3636
# @raise [ArgumentError] if the initial value is not a `Fixnum`
3737
def initialize(initial = 0)
38-
super(initial)
38+
super()
39+
synchronize { ns_initialize(initial) }
3940
end
4041

4142
# @!macro [attach] atomic_fixnum_method_value_get

lib/concurrent/atomic/copy_on_notify_observer_set.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ module Concurrent
88
# prevent concurrency issues
99
class CopyOnNotifyObserverSet < Synchronization::Object
1010

11+
def initialize
12+
super()
13+
synchronize { ns_initialize }
14+
end
15+
1116
# Adds an observer to this set. If a block is passed, the observer will be
1217
# created by this method and no other params should be passed
1318
#
@@ -24,7 +29,7 @@ def add_observer(observer=nil, func=:update, &block)
2429

2530
if block
2631
observer = block
27-
func = :call
32+
func = :call
2833
end
2934

3035
synchronize do

lib/concurrent/atomic/copy_on_write_observer_set.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ module Concurrent
77
# duplicated and replaced with a new one.
88
class CopyOnWriteObserverSet < Synchronization::Object
99

10+
def initialize
11+
super()
12+
synchronize { ns_initialize }
13+
end
14+
1015
# Adds an observer to this set
1116
# If a block is passed, the observer will be created by this method and no
1217
# other params should be passed

lib/concurrent/atomic/count_down_latch.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def initialize(count = 1)
2424
unless count.is_a?(Fixnum) && count >= 0
2525
raise ArgumentError.new('count must be in integer greater than or equal zero')
2626
end
27-
super(count)
27+
super()
28+
synchronize { ns_initialize count }
2829
end
2930

3031
# @!macro [attach] count_down_latch_method_wait

lib/concurrent/atomic/cyclic_barrier.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def initialize(parties, &block)
1818
if !parties.is_a?(Fixnum) || parties < 1
1919
raise ArgumentError.new('count must be in integer greater than or equal zero')
2020
end
21-
super(parties, &block)
21+
super(&nil)
22+
synchronize { ns_initialize parties, &block }
2223
end
2324

2425
# @return [Fixnum] the number of threads needed to pass the barrier

lib/concurrent/atomic/event.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Event < Synchronization::Object
1919
# `Event` will block.
2020
def initialize
2121
super
22+
synchronize { ns_initialize }
2223
end
2324

2425
# Is the object in the set state?

0 commit comments

Comments
 (0)