[Rails] Re: Database Concurrency Without a Web Server?

Francis Cianfrocca
Wed, 12 Jul 2006 23:15:18 -0000

Don, would it help if we added something like this to the
EventMachine...

You know how Python''s Twisted has something called a
"deferred"?
Basically an operation you kick off and you supply a callback that gets
called when the operation completes.

What if EventMachine had this:

op = proc {
  # You initiate a database operation here...
}
callback = proc {|result|
  # You process the result here.
}

EventMachine.schedule_operation( op, proc )

The call to #schedule_operation would probably have an options parameter
so you could specify concurrency levels, thread-safety, etc. The
operation block would be scheduled into a thread pool maintained by the
event-machine, but the result block would be called on the main
event-machine thread as an event like any other.

Comments?