Class: TD::UpdateManager

Inherits:
Object
  • Object
show all
Defined in:
lib/tdlib/update_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#handlersObject (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

#stopObject



22
23
24
# File 'lib/tdlib/update_manager.rb', line 22

def stop
  @stopped = true
end

#stopped?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/tdlib/update_manager.rb', line 26

def stopped?
  !!@stopped
end