Class: TD::UpdateManager
- Inherits:
-
Object
- Object
- TD::UpdateManager
- Defined in:
- lib/tdlib/update_manager.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
- #add_handler(handler) ⇒ Object
-
#initialize(td_client) ⇒ UpdateManager
constructor
A new instance of UpdateManager.
- #remove_handler(handler) ⇒ Object
- #stop ⇒ Object
- #stopped? ⇒ Boolean
Constructor Details
#initialize(td_client) ⇒ UpdateManager
Returns a new instance of UpdateManager.
4 5 6 7 8 9 10 |
# File 'lib/tdlib/update_manager.rb', line 4 def initialize(td_client) @td_client = td_client @handlers = [] @handlers_for_removal = [] @mutex = Mutex.new init_update_loop end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
2 3 4 |
# File 'lib/tdlib/update_manager.rb', line 2 def handlers @handlers end |
Instance Method Details
#add_handler(handler) ⇒ Object
12 13 14 |
# File 'lib/tdlib/update_manager.rb', line 12 def add_handler(handler) @mutex.synchronize { @handlers << handler } end |
#remove_handler(handler) ⇒ Object
16 17 18 19 20 |
# File 'lib/tdlib/update_manager.rb', line 16 def remove_handler(handler) Thread.start do @mutex.synchronize { @handlers.delete(handler) } end end |
#stop ⇒ Object
22 23 24 |
# File 'lib/tdlib/update_manager.rb', line 22 def stop @stopped = true end |
#stopped? ⇒ Boolean
26 27 28 |
# File 'lib/tdlib/update_manager.rb', line 26 def stopped? !!@stopped end |