File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 5
5
require 'concurrent/synchronization/jruby_object'
6
6
require 'concurrent/synchronization/rbx_object'
7
7
require 'concurrent/synchronization/object'
8
+ require 'concurrent/synchronization/volatile'
8
9
9
10
require 'concurrent/synchronization/abstract_lockable_object'
10
11
require 'concurrent/synchronization/mri_lockable_object'
Original file line number Diff line number Diff line change
1
+ module Concurrent
2
+ module Synchronization
3
+
4
+ # Volatile adds the attr_volatile class method when included.
5
+ #
6
+ # @example
7
+ # class Foo
8
+ # include Concurrent::Synchronization::Volatile
9
+ #
10
+ # attr_volatile :bar
11
+ #
12
+ # def initialize
13
+ # @volatile_bar = 1
14
+ # end
15
+ # end
16
+ #
17
+ # foo = Foo.new
18
+ # foo.bar
19
+ # => 1
20
+ # foo.bar = 2
21
+ # => 2
22
+
23
+ Volatile = case
24
+ when Concurrent . on_cruby?
25
+ MriAttrVolatile
26
+ when Concurrent . on_jruby?
27
+ JRubyAttrVolatile
28
+ when Concurrent . on_rbx?
29
+ RbxAttrVolatile
30
+ else
31
+ warn 'Possibly unsupported Ruby implementation'
32
+ MriAttrVolatile
33
+ end
34
+ end
35
+ end
You can’t perform that action at this time.
0 commit comments