Sha256: fc2809f80e0dcb605f0e94aa9c892f25b1e446d2d24977167e960bb2ed21e010
Contents?: true
Size: 712 Bytes
Versions: 14
Compression:
Stored size: 712 Bytes
Contents
require 'monitor' Module.class_eval do def synchronize_method *methods methods.each do |method| raise "can't synchronize system method #{method}" if method =~ /^__/ als = "sync_#{escape_method(method)}".to_sym raise "can't synchronize the '#{method}' twice!" if instance_methods.include?(als) alias_method als, method script = "\ def #{method} *p, &b @monitor ||= Monitor.new @monitor.synchronize{#{als} *p, &b} end" class_eval script, __FILE__, __LINE__ end end def synchronize_all_methods include_super = false methods = self.instance_methods(include_super).collect{|m| m} synchronize_method *methods end end
Version data entries
14 entries across 14 versions & 1 rubygems