Class: Idb::SnoopItUpdateThread
- Inherits:
-
Qt::Object
- Object
- Qt::Object
- Idb::SnoopItUpdateThread
- Defined in:
- lib/gui/snoop_it_update_thread.rb
Instance Attribute Summary collapse
-
#thread ⇒ Object
Returns the value of attribute thread.
Instance Method Summary collapse
- #delete_all ⇒ Object
-
#initialize(*args) ⇒ SnoopItUpdateThread
constructor
A new instance of SnoopItUpdateThread.
- #stream(function) ⇒ Object
Constructor Details
#initialize(*args) ⇒ SnoopItUpdateThread
Returns a new instance of SnoopItUpdateThread.
6 7 8 9 10 11 |
# File 'lib/gui/snoop_it_update_thread.rb', line 6 def initialize *args super *args STDOUT.sync = true @snoop = SnoopItWrapper.new end |
Instance Attribute Details
#thread ⇒ Object
Returns the value of attribute thread.
4 5 6 |
# File 'lib/gui/snoop_it_update_thread.rb', line 4 def thread @thread end |
Instance Method Details
#delete_all ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/gui/snoop_it_update_thread.rb', line 13 def delete_all begin @snoop.fsevents_delete rescue puts "Connection lost" end end |
#stream(function) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gui/snoop_it_update_thread.rb', line 21 def stream function puts "Starting" @id = 0 puts @id t = Qt::Timer.new self t.connect(SIGNAL(:timeout)) { puts "triggered" thread = Thread.new do begin events = @snoop.send(function, @id) rescue puts "Connection lost" t.stop thread.kill end @id = events.last["id"] unless events.last.nil? puts @id emit new_events(events.to_variant) unless events.nil? end thread.join } t.start(1000) end |