/usr/lib/ruby/vendor_ruby/thread_safe/util/atomic_reference.rb is in ruby-thread-safe 0.3.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | module ThreadSafe
module Util
AtomicReference =
if defined?(Rubinius::AtomicReference)
# An overhead-less atomic reference.
Rubinius::AtomicReference
else
begin
require 'atomic'
defined?(Atomic::InternalReference) ? Atomic::InternalReference : Atomic
rescue LoadError, NameError
class FullLockingAtomicReference
def initialize(value = nil)
@___mutex = Mutex.new
@___value = value
end
def get
@___mutex.synchronize { @___value }
end
alias_method :value, :get
def set(new_value)
@___mutex.synchronize { @___value = new_value }
end
alias_method :value=, :set
def compare_and_set(old_value, new_value)
return false unless @___mutex.try_lock
begin
return false unless @___value.equal? old_value
@___value = new_value
ensure
@___mutex.unlock
end
true
end
end
FullLockingAtomicReference
end
end
end
end
|