Class: Quicsilver::Transport::EventLoop
- Inherits:
-
Object
- Object
- Quicsilver::Transport::EventLoop
- Defined in:
- lib/quicsilver/transport/event_loop.rb
Instance Method Summary collapse
-
#initialize ⇒ EventLoop
constructor
A new instance of EventLoop.
- #join ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ EventLoop
Returns a new instance of EventLoop.
6 7 8 9 10 |
# File 'lib/quicsilver/transport/event_loop.rb', line 6 def initialize @running = false @thread = nil @mutex = Mutex.new end |
Instance Method Details
#join ⇒ Object
29 30 31 |
# File 'lib/quicsilver/transport/event_loop.rb', line 29 def join @thread&.join end |
#start ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/quicsilver/transport/event_loop.rb', line 12 def start @mutex.synchronize do return if @running @running = true @thread = Thread.new do Quicsilver.poll while @running end end end |
#stop ⇒ Object
23 24 25 26 27 |
# File 'lib/quicsilver/transport/event_loop.rb', line 23 def stop @running = false Quicsilver.wake @thread&.join(2) end |