Parent

Included Modules

Class/Module Index [+]

Quicksearch

Object

Public Instance Methods

ancestors() click to toggle source
# File lib/sup/util.rb, line 121
def ancestors
  ret = []
  klass = self.class

  until klass == Object
    ret << klass
    klass = klass.superclass
  end
  ret
end
id() click to toggle source

this is for debugging purposes because i keep calling id on the wrong object and i want it to throw an exception

# File lib/sup.rb, line 16
def id
  raise "wrong id called on #{self.inspect}"
end
ignore_concurrent_calls(*methods) click to toggle source
# File lib/sup/util.rb, line 149
def ignore_concurrent_calls *methods
  methods.each do |meth|
    mutex = "@__concurrent_protector_#{meth}"
    flag = "@__concurrent_flag_#{meth}"
    oldmeth = "__unprotected_#{meth}"
    class_eval         alias #{oldmeth} #{meth}        def #{meth}(*a, &b)          #{mutex} = Mutex.new unless defined? #{mutex}          #{flag} = true unless defined? #{flag}          run = #{mutex}.synchronize do            if #{flag}              #{flag} = false              true            end          end          if run            ret = #{oldmeth}(*a, &b)            #{mutex}.synchronize { #{flag} = true }            ret          end        end
  end
end
returning(x;) click to toggle source

"k combinator"

# File lib/sup/util.rb, line 133
def returning x; yield x; x; end
synchronized(*methods) click to toggle source

clone of java-style whole-method synchronization assumes a @mutex variable TODO: clean up, try harder to avoid namespace collisions

# File lib/sup/util.rb, line 138
def synchronized *methods
  methods.each do |meth|
    class_eval         alias unsynchronized_#{meth} #{meth}        def #{meth}(*a, &b)          @mutex.synchronize { unsynchronized_#{meth}(*a, &b) }        end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.