Sha256: 0bd4c7e955dd385f00c955b7bf083d68f5eb36ce983c8deac68d6e77d764d005

Contents?: true

Size: 686 Bytes

Versions: 104

Compression:

Stored size: 686 Bytes

Contents

=begin rdoc
  Make a command thread-safe
=end
require "monitor"
module PoolParty
  extend self
  
  module ThreadSafeInstance
    
    module ClassMethods
      def make_safe(meth)
       original_method = "_unsafe_#{meth}_"
       alias_method original_method, meth
       define_method(meth) {|*args| self.class.synchronize { self.send(original_method) } }
       self
      end  
    end
    
    module InstanceMethods
      def make_safe meth
        self.class.make_safe meth
      end
    end
    
    def self.included(receiver)
      receiver.extend         MonitorMixin
      receiver.extend         ClassMethods
      receiver.send :include, InstanceMethods
    end
  end
end

Version data entries

104 entries across 104 versions & 5 rubygems

Version Path
auser-poolparty-0.2.58 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.59 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.6 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.60 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.61 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.62 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.63 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.64 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.65 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.66 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.67 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.68 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.69 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.70 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.71 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.72 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.74 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.76 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.77 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.78 lib/poolparty/modules/safe_instance.rb