Module: Tsafe

Defined in:
lib/tsafe.rb

Overview

This module contains various tools to handle thread-safety easily and pretty.

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object

Autoloader for subclasses.



6
7
8
9
10
# File 'lib/tsafe.rb', line 6

def self.const_missing(name)
  require "#{File.dirname(__FILE__)}/../include/#{name.to_s.downcase}.rb"
  raise "Still not loaded: '#{name}'." if !Tsafe.const_defined?(name)
  return Tsafe.const_get(name)
end

.std_arrayObject

JRuby can corrupt an array in a threadded env. Use this method to only get a synchronized array when running JRuby and not having to write “if RUBY_ENGINE”-stuff.



13
14
15
16
# File 'lib/tsafe.rb', line 13

def self.std_array
  return MonArray.new if RUBY_ENGINE == "jruby"
  return []
end