File tree Expand file tree Collapse file tree 6 files changed +51
-6
lines changed
lib/concurrent/synchronization Expand file tree Collapse file tree 6 files changed +51
-6
lines changed Original file line number Diff line number Diff line change 1
1
language : ruby
2
2
3
3
rvm :
4
+ - 2.2.3
4
5
- 2.2.2
5
6
- 2.1.5
6
7
- 2.1.4
7
8
- 2.0.0
8
9
- 1.9.3
9
10
- ruby-head
10
11
- jruby-1.7.19
11
- - jruby-9.0.0.0
12
- - jruby-9.0.1.0
13
12
- jruby-9.0.3.0
13
+ - jruby-9.0.4.0
14
14
- jruby-head
15
15
- rbx-2
16
16
Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ module Synchronization
10
10
MriMutexLockableObject
11
11
when Concurrent . on_jruby?
12
12
JRubyLockableObject
13
- when Concurrent . on_rbx? || Concurrent . on_truffle?
13
+ when Concurrent . on_rbx?
14
14
RbxLockableObject
15
+ when Concurrent . on_truffle?
16
+ TruffleLockableObject
15
17
else
16
18
warn 'Possibly unsupported Ruby implementation'
17
19
MriMonitorLockableObject
Original file line number Diff line number Diff line change @@ -8,8 +8,10 @@ module Synchronization
8
8
MriObject
9
9
when Concurrent . on_jruby?
10
10
JRubyObject
11
- when Concurrent . on_rbx? || Concurrent . on_truffle?
11
+ when Concurrent . on_rbx?
12
12
RbxObject
13
+ when Concurrent . on_truffle?
14
+ TruffleObject
13
15
else
14
16
MriObject
15
17
end
@@ -49,8 +51,8 @@ def self.safe_initialization!
49
51
# define only once, and not again in children
50
52
return if safe_initialization?
51
53
52
- def self . new ( *)
53
- object = super
54
+ def self . new ( *args , & block )
55
+ object = super ( * args , & block )
54
56
ensure
55
57
object . full_memory_barrier if object
56
58
end
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ def self.included(base)
7
7
end
8
8
9
9
module ClassMethods
10
+
10
11
def attr_volatile ( *names )
11
12
names . each do |name |
12
13
ivar = :"@volatile_#{ name } "
@@ -24,6 +25,7 @@ def #{name}=(value)
24
25
end
25
26
names . map { |n | [ n , :"#{ n } =" ] } . flatten
26
27
end
28
+
27
29
end
28
30
29
31
def full_memory_barrier
Original file line number Diff line number Diff line change
1
+ module Concurrent
2
+ module Synchronization
3
+ class TruffleLockableObject
4
+ raise NotImplementedError
5
+ end
6
+ end
7
+ end
Original file line number Diff line number Diff line change
1
+ module Concurrent
2
+ module Synchronization
3
+
4
+ module TruffleAttrVolatile
5
+ def self . included ( base )
6
+ base . extend ( ClassMethods )
7
+ end
8
+
9
+ module ClassMethods
10
+ def attr_volatile ( *names )
11
+ # TODO may not always be available
12
+ attr_atomic ( *names )
13
+ end
14
+ end
15
+
16
+ def full_memory_barrier
17
+ # Rubinius instance variables are not volatile so we need to insert barrier
18
+ Rubinius . memory_barrier
19
+ end
20
+ end
21
+
22
+ # @!visibility private
23
+ # @!macro internal_implementation_note
24
+ class TruffleObject < AbstractObject
25
+ include TruffleAttrVolatile
26
+
27
+ def initialize
28
+ # nothing to do
29
+ end
30
+ end
31
+ end
32
+ end
You can’t perform that action at this time.
0 commit comments