Class: Cinch::Callback Private
- Inherits:
-
Object
- Object
- Cinch::Callback
- Includes:
- Helpers
- Defined in:
- lib/cinch/callback.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #bot ⇒ Bot readonly private
Instance Method Summary collapse
-
#initialize(bot) ⇒ Callback
constructor
private
A new instance of Callback.
-
#synchronize(*args) { ... } ⇒ void
private
Since Cinch uses threads, all handlers can be run simultaneously, even the same handler multiple times.
Methods included from Helpers
Constructor Details
#initialize(bot) ⇒ Callback
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Callback.
8 9 10 |
# File 'lib/cinch/callback.rb', line 8 def initialize(bot) @bot = bot end |
Instance Attribute Details
#bot ⇒ Bot (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 |
# File 'lib/cinch/callback.rb', line 7 def bot @bot end |
Instance Method Details
#synchronize(*args) { ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Since Cinch uses threads, all handlers can be run simultaneously, even the same handler multiple times. This also means, that your code has to be thread-safe. Most of the time, this is not a problem, but if you are accessing stored data, you will most likely have to synchronize access to it. Instead of managing all mutexes yourself, Cinch provides a synchronize method, which takes a name and block.
Synchronize blocks with the same name share the same mutex, which means that only one of them will be executed at a time.
13 14 15 |
# File 'lib/cinch/callback.rb', line 13 def synchronize(*args, &block) @bot.synchronize(*args, &block) end |