Module: Radio::Rig::Rx

Included in:
Radio::Rig
Defined in:
lib/radio/rig/rx.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



22
23
24
25
# File 'lib/radio/rig/rx.rb', line 22

def initialize
  @rx = @rx_thread = nil
  super
end

#rx=(input) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/radio/rig/rx.rb', line 27

def rx= input
  old_rx_thread = false
  @semaphore.synchronize do
    if @rx
      @rx.stop
      old_rx_thread = @rx_thread
      old_rx_thread.kill
    end
    if @rx = input
      @rx_thread = Thread.new &method(:rx_thread)
    end
  end
  old_rx_thread.join if old_rx_thread
end