Class: Quicsilver::Transport::EventLoop

Inherits:
Object
  • Object
show all
Defined in:
lib/quicsilver/transport/event_loop.rb

Instance Method Summary collapse

Constructor Details

#initializeEventLoop

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

#joinObject



29
30
31
# File 'lib/quicsilver/transport/event_loop.rb', line 29

def join
  @thread&.join
end

#startObject



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

#stopObject



23
24
25
26
27
# File 'lib/quicsilver/transport/event_loop.rb', line 23

def stop
  @running = false
  Quicsilver.wake
  @thread&.join(2)
end