Class: EMRPC::Timer
- Includes:
- Pid
- Defined in:
- lib/emrpc/evented_api/timer.rb
Constant Summary
Constants included from ProtocolMapper
Instance Attribute Summary
Attributes included from Pid
#_bind_address, #_em_server_signature, #_protocol, #connections, #killed, #options, #uuid
Instance Method Summary collapse
-
#initialize(pid, options) ⇒ Timer
constructor
A new instance of Timer.
Methods included from Pid
#==, #_send_dirty, #_uid, #bind, #connect, #connection_established, #connection_unbind, #connection_uuids, #disconnect, #encode_b381b571_1ab2_5889_8221_855dbbc76242, #find_pid, #inspect, #kill, #killed?, #marshal_dump, #marshal_load, new, #pid_class_name, #spawn, #tcp_spawn, #thread_spawn
Methods included from DebugPidCallbacks
#_debug, #connected, #connection_failed, #disconnected, #handshake_failed, #on_raise, #on_return
Methods included from ProtocolMapper
#make_client_connection, #make_server_connection, register_protocol
Methods included from DefaultCallbacks
#connected, #connection_failed, #disconnected, #handshake_failed, #on_raise, #on_return
Constructor Details
#initialize(pid, options) ⇒ Timer
Returns a new instance of Timer.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/emrpc/evented_api/timer.rb', line 4 def initialize(pid, ) super @pid = [:pid] or raise "Option :pid is missing!" @interval = [:interval] @delay = [:delay] @callback = [:callback] || :on_timer if @interval EventMachine::PeriodicTimer.new(@interval) do @pid.__send__(@callback) end else @delay or raise "Options :delay or :interval are missing!" EventMachine::Timer.new(@delay) do @pid.__send__(@callback) kill end end end |