Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EM::Deferrable replacement #4

Closed
imanel opened this issue Dec 15, 2010 · 6 comments
Closed

EM::Deferrable replacement #4

imanel opened this issue Dec 15, 2010 · 6 comments

Comments

@imanel
Copy link

imanel commented Dec 15, 2010

I'm currently using EventMachine, but Cool.IO seems nicer to me(and I think that libev is faster that libevent), but after checking all source I can't find anything like EM::Deferrable - is it unnecessary in Cool.IO or it is just not implemented yet?

@tarcieri
Copy link
Collaborator

There's nothing like EM::Deferrable right now, sorry. I'll leave this ticket open as a feature request.

@imanel
Copy link
Author

imanel commented Dec 16, 2010

Then is there suggested way to write long running tasks that will not lock reactor? To make example:

require 'rubygems'
require 'cool.io'

ADDR = '127.0.0.1'
PORT = 4321

cool.io.connection :echo_server_connection do
  on_connect do
    sleep 1
    puts "#{remote_addr}:#{remote_port} connected"
  end
end

cool.io.server ADDR, PORT, :echo_server_connection
cool.io.run

I want this to allow accepting another connection before sleep is over. Any suggestions?

@tarcieri
Copy link
Collaborator

You can spin off long running tasks in separate threads. To unblock the event loop, you can use an AsyncWatcher:

https://github.com/tarcieri/cool.io/blob/master/lib/cool.io/async_watcher.rb

@igrigorik
Copy link

+1 for deferrable mixin.. So much of existing EM code relies on deferrables that not having it in cool.io makes transition pretty painful.

@tarcieri
Copy link
Collaborator

Let me revisit this...

@AE9RB
Copy link

AE9RB commented Jul 18, 2011

I just moved https://github.com/dturnbull/ruby-redis to cool.io. I pulled in EM::Deferrable but I think its interface is wonky and the timer won't work so I have a new one designed that I'll be writing up this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants