Created
August 11, 2014 19:10
-
-
Save emschwar/f30e4b4cc7c531037ed1 to your computer and use it in GitHub Desktop.
Proposal for a dummy queue solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/blather/client/client.rb b/lib/blather/client/client.rb | |
index 6c7fe4e..9e8350b 100644 | |
--- a/lib/blather/client/client.rb | |
+++ b/lib/blather/client/client.rb | |
@@ -184,11 +184,7 @@ module Blather | |
# @private | |
def receive_data(stanza) | |
- if handler_queue | |
- handler_queue << stanza | |
- else | |
- handle_data stanza | |
- end | |
+ handler_queue << stanza | |
end | |
def handle_data(stanza) | |
@@ -216,12 +212,26 @@ module Blather | |
self | |
end | |
+ class FakeQueue | |
+ def initialize(client) | |
+ @client = client | |
+ end | |
+ | |
+ def <<(stanza) | |
+ @client.handle_data stanza | |
+ end | |
+ end | |
+ | |
# @private | |
def handler_queue | |
- return if queue_size == 0 | |
- @handler_queue ||= GirlFriday::WorkQueue.new :handle_stanza, :size => queue_size do |stanza| | |
+ return @handler_queue if @handler_queue | |
+ | |
+ @handler_queue = GirlFriday::WorkQueue.new :handle_stanza, :size => queue_size do |stanza| | |
handle_data stanza | |
- end | |
+ end if queue_size.to_i > 0 | |
+ @handler_queue ||= FakeQueue.new(self) | |
+ | |
+ @handler_queue | |
end | |
protected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment