Module: Concurrent::ThreadSafe::Util
Constant Summary
-
CPU_COUNT =
TODO (pitr-ch 15-Oct-2016): migrate to
Utility::ProcessorCounter
16
-
FIXNUM_BIT_SIZE =
TODO (pitr-ch 15-Oct-2016): migrate to
Utility::NativeInteger
(0.size * 8) - 2
-
MAX_INT =
# File 'lib/concurrent-ruby/concurrent/thread_safe/util.rb', line 11(2 ** FIXNUM_BIT_SIZE) - 1
Class Method Summary
Class Method Details
.make_synchronized_on_cruby(klass)
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb', line 16
def self.make_synchronized_on_cruby(klass) klass.class_eval do def initialize(*args, &block) @_monitor = Monitor.new super end def initialize_copy(other) # make sure a copy is not sharing a monitor with the original object! @_monitor = Monitor.new super end end klass.superclass.instance_methods(false).each do |method| klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{method}(*args) monitor = @_monitor monitor or raise("BUG: Internal monitor was not properly initialized. Please report this to the concurrent-ruby developers.") monitor.synchronize { super } end RUBY end end
.make_synchronized_on_truffleruby(klass)
[ GitHub ]# File 'lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb', line 41
def self.make_synchronized_on_truffleruby(klass) klass.superclass.instance_methods(false).each do |method| klass.class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{method}(*args, &block) TruffleRuby.synchronized(self) { super(*args, &block) } end RUBY end end