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

Jia Liu
Thu, 13 Jul 2006 06:59:10 -0000

Hi, Francis, finally see some twisted fans in ruby world;-)
I always wonder why there isn''t a similar thing in ruby,
it will be too cool.
I think it makes a great google SoC project.
Francis Cianfrocca wrote:
> 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?