You could use eventmachine. 

EM.run do
  non_blocking = proc { |args| ... }
  EM.defer non_blocking do |result|
    # do something
  end
end


Dave Newman 
@whatupdave


On Friday, 2 December 2011 at 3:00 PM, Dmytrii Nagirniak wrote:

> Hi,
> 
> I wonder how is it possible to do execute callbacks in a non-blocking manner 
> (asynchronously) *cheaply*?
> 
> So something like this:
> 
> non_blocking(arguments) do |result|
>   # Do something with the result
> end
> 
> Calling `request_something` should not block, but rather continue execution.
> The easiest way is probably using Fibers. But Fibers are not cheap and depend 
> on the platform.
> For example, JRuby uses Threads, so it is pretty expensive. 1.8 doesn't have 
> Fibers at all AFAIK.
> 
> What are the other Nodejs-ish alternatives for that?
> 
> Cheers,
> Dima
> http://www.ApproachE.com
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected] 
> (mailto:[email protected]).
> To unsubscribe from this group, send email to 
> [email protected] 
> (mailto:[email protected]).
> For more options, visit this group at 
> http://groups.google.com/group/rails-oceania?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to