Class: Ansible::Transceiver
- Inherits:
-
Object
- Object
- Ansible::Transceiver
- Defined in:
- lib/ansible/transceiver.rb
Overview
Generic Ansible tranceiver spawns a Ruby thread to call run()
Direct Known Subclasses
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize ⇒ Transceiver
constructor
A new instance of Transceiver.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Transceiver
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
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
31 32 33 |
# File 'lib/ansible/transceiver.rb', line 31 def thread @thread end |
Instance Method Details
#run ⇒ Object
50 51 52 |
# File 'lib/ansible/transceiver.rb', line 50 def run raise "Must override Tranceiver.run() method!!!" end |
#stop ⇒ Object
54 55 56 |
# File 'lib/ansible/transceiver.rb', line 54 def stop() @thread.stop end |