Class: Module

Inherits:
Object
  • Object
show all
Defined in:
lib/plllayer/synchronize.rb

Instance Method Summary collapse

Instance Method Details

#synchronize(method, mutex_name) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/plllayer/synchronize.rb', line 2

def synchronize(method, mutex_name)
  alias_method :"_unsynchronized_#{method}", method.to_sym
  define_method(method.to_sym) do |*args, &blk|
    instance_variable_get(mutex_name.to_sym).synchronize do
      send(:"_unsynchronized_#{method}", *args, &blk)
    end
  end
end