Skip to content

Instantly share code, notes, and snippets.

@adimircolen
Created September 23, 2010 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adimircolen/594379 to your computer and use it in GitHub Desktop.
Save adimircolen/594379 to your computer and use it in GitHub Desktop.
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