Module: MessagePack::RPC::LoopUtil
Defined Under Namespace
Classes: TaskQueue, Timer
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#loop ⇒ Object
Returns the value of attribute loop.
26
27
28
|
# File 'lib/msgpack/rpc/loop.rb', line 26
def loop
@loop
end
|
Instance Method Details
#run ⇒ Object
72
73
74
|
# File 'lib/msgpack/rpc/loop.rb', line 72
def run
@loop.run
end
|
#start_timer(interval, repeating, &block) ⇒ Object
38
39
40
|
# File 'lib/msgpack/rpc/loop.rb', line 38
def start_timer(interval, repeating, &block)
@loop.attach Timer.new(interval, repeating, &block)
end
|
#stop ⇒ Object
76
77
78
79
80
81
82
|
# File 'lib/msgpack/rpc/loop.rb', line 76
def stop
@queue.detach if @queue && @queue.attached?
@loop.stop
@loop.attach Cool.io::TimerWatcher.new(0, false)
nil
end
|
#submit(task = nil, &block) ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'lib/msgpack/rpc/loop.rb', line 63
def submit(task = nil, &block)
task ||= block
unless @queue
@queue = TaskQueue.new
@loop.attach(@queue)
end
@queue.push(task)
end
|