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.0.8 lib/modules/safe_instance.rb
auser-poolparty-0.0.9 lib/modules/safe_instance.rb
auser-poolparty-0.1.0 lib/modules/safe_instance.rb
auser-poolparty-0.1.1 lib/modules/safe_instance.rb
auser-poolparty-0.1.2 lib/modules/safe_instance.rb
auser-poolparty-0.2.15 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.16 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.2 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.20 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.21 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.22 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.23 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.24 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.25 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.26 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.3 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.35 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.36 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.37 lib/poolparty/modules/safe_instance.rb
auser-poolparty-0.2.38 lib/poolparty/modules/safe_instance.rb