Class: UU::RemoteHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/drb/http0helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRemoteHelper

Returns a new instance of RemoteHelper.



21
22
23
24
# File 'lib/drb/http0helper.rb', line 21

def initialize
  @mutex = Mutex.new
  @count = 0
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



26
27
28
# File 'lib/drb/http0helper.rb', line 26

def count
  @count
end

Instance Method Details

#disableObject



28
29
30
31
32
33
# File 'lib/drb/http0helper.rb', line 28

def disable
  @mutex.synchronize do
    @count += 1
    GC.disable
  end
end

#enableObject



35
36
37
38
39
40
41
42
# File 'lib/drb/http0helper.rb', line 35

def enable
  @mutex.synchronize do
    @count -= 1
    break unless @count <= 0

    GC.enable
  end
end

#eval_(code) ⇒ Object



51
52
53
# File 'lib/drb/http0helper.rb', line 51

def eval_(code)
  instance_eval(code)
end

#klass(name) ⇒ Object



55
56
57
# File 'lib/drb/http0helper.rb', line 55

def klass(name)
  eval_(name.to_s)
end

#resetObject



44
45
46
47
48
49
# File 'lib/drb/http0helper.rb', line 44

def reset
  @mutex.synchronize do
    @count = 0
    GC.enable
  end
end