Created
September 23, 2010 21:16
-
-
Save adimircolen/594379 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'eventmachine' | |
##require 'lib/environment' # here we go again! | |
EM.kqueue = true if EM.kqueue? # file watching requires kqueue on OSX | |
class Example < EM::Connection | |
def receive_data(data) | |
#BlockConn.fila.size+1 | |
Example.queue.push "#{data}" | |
p "No-Block for other request #{data}" | |
end | |
def Example.queue | |
@fila ||= begin | |
q = EM::Queue.new | |
processor = proc{ |msg| | |
#sleep(5) | |
(0...9999999).each{|i| (i%2.0)**i } | |
p "In queue #{msg.to_i+1}" | |
q.pop(&processor) | |
} | |
q.pop(&processor) | |
q | |
end | |
end | |
end | |
EM.run do | |
EM.start_server(HOST, HOST_PORT, Example) | |
end | |
puts("Shutdown this service") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment