Sha256: 3b1b0af99dc450b9459e0b9a4758f36db56b0f089a05ce51e96429135cac8413

Contents?: true

Size: 622 Bytes

Versions: 3

Compression:

Stored size: 622 Bytes

Contents

require "monitor"

#This module contains various tools to handle thread-safety easily and pretty.
module Tsafe
  #Autoloader for subclasses.
  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
  
  #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.
  def self.std_array
    return MonArray.new if RUBY_ENGINE == "jruby"
    return []
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tsafe-0.0.4 lib/tsafe.rb
tsafe-0.0.3 lib/tsafe.rb
tsafe-0.0.2 lib/tsafe.rb