What is the best way to schedule something for delayed asynchronous
execution? Basically, I want to say "in 20 seconds, execute this
function / block / proc / lambda / webhook or whatever".

Also: this will be used by a rack-based web app, so I need a solution
that will keep working if Passenger restarts instances of the
application. Would a Thread.new(delay) {|delay| sleep delay; ...} type
of solution work in such a scenario? Does using Thread like this consume
lots of memory?

How have you solved this in the past? I would like to avoid installing
daemons if possible.

I was thinking of doing something like below, but I'm not sure it will
be reliable in a web app environment:

def call_async(code, delay=0)
  Thread.new(delay, code) {|d,c| sleep d; c.call}
end
-- 
Posted via http://www.ruby-forum.com/.