Class: Ansible::Transceiver

Inherits:
Object
  • Object
show all
Defined in:
lib/ansible/transceiver.rb

Overview

Generic Ansible tranceiver spawns a Ruby thread to call run()

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTransceiver

Returns a new instance of Transceiver.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ansible/transceiver.rb', line 33

def initialize()
    begin
        @thread = Thread.new {
            begin
                run()
            rescue Exception => e
                puts "----#{self.class.name.upcase} EXCEPTION: #{e} ----"
                puts "backtrace:\n\t" + e.backtrace.join("\n\t")
            end
        }
    rescue Exception => e
        puts("Cannot spawn worker thread, #{e}")
        puts("backtrace:\n\t" << e.backtrace.join("\n\t"))
        exit(-1)
    end
end

Instance Attribute Details

#threadObject (readonly)

Returns the value of attribute thread.



31
32
33
# File 'lib/ansible/transceiver.rb', line 31

def thread
  @thread
end

Instance Method Details

#runObject



50
51
52
# File 'lib/ansible/transceiver.rb', line 50

def run
    raise "Must override Tranceiver.run() method!!!"
end

#stopObject



54
55
56
# File 'lib/ansible/transceiver.rb', line 54

def stop()
    @thread.stop
end