Class: Foolio::Loop
Instance Attribute Summary collapse
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
Class Method Summary collapse
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #file_stat(path, &block) ⇒ Object
- #force_stop ⇒ Object
- #idle ⇒ Object
-
#initialize(loop) ⇒ Loop
constructor
A new instance of Loop.
- #run ⇒ Object
- #stop ⇒ Object
- #tcp(ip, port) ⇒ Object
- #timer ⇒ Object
- #udp ⇒ Object
- #unix(path, ipc = 0) ⇒ Object
Methods included from Listener
Constructor Details
Instance Attribute Details
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
6 7 8 |
# File 'lib/foolio/loop.rb', line 6 def loop @loop end |
Class Method Details
.create ⇒ Object
12 13 14 |
# File 'lib/foolio/loop.rb', line 12 def create self.new Foolio::UV.loop_new end |
.default ⇒ Object
8 9 10 |
# File 'lib/foolio/loop.rb', line 8 def default self.new Foolio::UV.default_loop end |
Instance Method Details
#alive? ⇒ Boolean
66 67 68 |
# File 'lib/foolio/loop.rb', line 66 def alive? not @stop end |
#file_stat(path, &block) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/foolio/loop.rb', line 55 def file_stat(path, &block) cb = callback{|event, _| block[path, event] } Foolio::UV.fs_event_init(@loop, path, cb, 0) end |
#force_stop ⇒ Object
74 75 76 77 |
# File 'lib/foolio/loop.rb', line 74 def force_stop @stop = true Foolio::UV.loop_delete @loop end |
#idle ⇒ Object
29 30 31 |
# File 'lib/foolio/loop.rb', line 29 def idle Foolio::Idle.new(self, Foolio::UV.idle_init(@loop)) end |
#run ⇒ Object
62 63 64 |
# File 'lib/foolio/loop.rb', line 62 def run Foolio::UV.run @loop end |
#stop ⇒ Object
70 71 72 |
# File 'lib/foolio/loop.rb', line 70 def stop @stop = true end |
#tcp(ip, port) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/foolio/loop.rb', line 37 def tcp(ip, port) handle = Foolio::UV.tcp_init(@loop) @socket = Foolio::UV.ip4_addr(ip, port) Foolio::UV.tcp_bind(handle, @socket) Foolio::TCP.new self, handle end |
#timer ⇒ Object
33 34 35 |
# File 'lib/foolio/loop.rb', line 33 def timer Foolio::Timer.new(self, Foolio::UV.timer_init(@loop)) end |