Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/lib/cinch/handler.rb b/lib/cinch/handler.rb
- index 41988b2..d673492 100644
- --- a/lib/cinch/handler.rb
- +++ b/lib/cinch/handler.rb
- @@ -74,11 +74,11 @@ module Cinch
- # @param [Message] message Message that caused the invocation
- # @param [Array] captures Capture groups of the pattern that are
- # being passed as arguments
- - # @return [void]
- + # @return [Thread]
- def call(message, captures, arguments)
- bargs = captures + arguments
- - @thread_group.add Thread.new {
- + thread = Thread.new {
- @bot.loggers.debug "[New thread] For #{self}: #{Thread.current} -- #{@thread_group.list.size} in total."
- begin
- @@ -93,6 +93,9 @@ module Cinch
- @bot.loggers.debug "[Thread done] For #{self}: #{Thread.current} -- #{@thread_group.list.size - 1} remaining."
- end
- }
- +
- + @thread_group.add thread
- + thread
- end
- # @return [String]
- diff --git a/lib/cinch/handler_list.rb b/lib/cinch/handler_list.rb
- index ffbd269..8e00cbf 100644
- --- a/lib/cinch/handler_list.rb
- +++ b/lib/cinch/handler_list.rb
- @@ -51,10 +51,11 @@ module Cinch
- # and attached to the event, or nil.
- # @param [Array] *arguments A list of additional arguments to pass
- # to event handlers
- - # @return [void]
- + # @return [Set<Thread>]
- def dispatch(event, msg = nil, *arguments)
- if handlers = find(event, msg)
- already_run = Set.new
- + threads = Set.new
- handlers.each do |handler|
- next if already_run.include?(handler.block)
- already_run << handler.block
- @@ -66,9 +67,10 @@ module Cinch
- captures = []
- end
- - handler.call(msg, captures, arguments)
- + threads << handler.call(msg, captures, arguments)
- end
- end
- + threads
- end
- # @yield [handler] Yields all registered handlers
Advertisement
Add Comment
Please, Sign In to add comment