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 11language : ruby
22
33rvm :
4+ - 2.2.3
45 - 2.2.2
56 - 2.1.5
67 - 2.1.4
78 - 2.0.0
89 - 1.9.3
910 - ruby-head
1011 - jruby-1.7.19
11- - jruby-9.0.0.0
12- - jruby-9.0.1.0
1312 - jruby-9.0.3.0
13+ - jruby-9.0.4.0
1414 - jruby-head
1515 - rbx-2
1616
Original file line number Diff line number Diff line change @@ -10,8 +10,10 @@ module Synchronization
1010 MriMutexLockableObject
1111 when Concurrent . on_jruby?
1212 JRubyLockableObject
13- when Concurrent . on_rbx? || Concurrent . on_truffle?
13+ when Concurrent . on_rbx?
1414 RbxLockableObject
15+ when Concurrent . on_truffle?
16+ TruffleLockableObject
1517 else
1618 warn 'Possibly unsupported Ruby implementation'
1719 MriMonitorLockableObject
Original file line number Diff line number Diff line change @@ -8,8 +8,10 @@ module Synchronization
88 MriObject
99 when Concurrent . on_jruby?
1010 JRubyObject
11- when Concurrent . on_rbx? || Concurrent . on_truffle?
11+ when Concurrent . on_rbx?
1212 RbxObject
13+ when Concurrent . on_truffle?
14+ TruffleObject
1315 else
1416 MriObject
1517 end
@@ -49,8 +51,8 @@ def self.safe_initialization!
4951 # define only once, and not again in children
5052 return if safe_initialization?
5153
52- def self . new ( *)
53- object = super
54+ def self . new ( *args , & block )
55+ object = super ( * args , & block )
5456 ensure
5557 object . full_memory_barrier if object
5658 end
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ def self.included(base)
77 end
88
99 module ClassMethods
10+
1011 def attr_volatile ( *names )
1112 names . each do |name |
1213 ivar = :"@volatile_#{ name } "
@@ -24,6 +25,7 @@ def #{name}=(value)
2425 end
2526 names . map { |n | [ n , :"#{ n } =" ] } . flatten
2627 end
28+
2729 end
2830
2931 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