Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
89 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 19 additions & 14 deletions
33
...nt/synchronization/mri_lockable_object.rb → .../synchronization/mutex_lockable_object.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Concurrent | ||
module Synchronization | ||
|
||
module TruffleRubyAttrVolatile | ||
def self.included(base) | ||
base.extend(ClassMethods) | ||
end | ||
|
||
module ClassMethods | ||
def attr_volatile(*names) | ||
names.each do |name| | ||
ivar = :"@volatile_#{name}" | ||
|
||
class_eval <<-RUBY, __FILE__, __LINE__ + 1 | ||
def #{name} | ||
full_memory_barrier | ||
#{ivar} | ||
end | ||
def #{name}=(value) | ||
#{ivar} = value | ||
full_memory_barrier | ||
end | ||
RUBY | ||
end | ||
|
||
names.map { |n| [n, :"#{n}="] }.flatten | ||
end | ||
end | ||
|
||
def full_memory_barrier | ||
TruffleRuby.full_memory_barrier | ||
end | ||
end | ||
|
||
# @!visibility private | ||
# @!macro internal_implementation_note | ||
class TruffleRubyObject < AbstractObject | ||
include TruffleRubyAttrVolatile | ||
|
||
def initialize | ||
# nothing to do | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters