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

snacktime
Thu, 13 Jul 2006 03:52:02 -0000

On 7/12/06, Francis Cianfrocca <garbagecat10@gmail.com>
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?

I think a thread pool for running code that will block is a great idea
while you are still working on all the different io handlers.  Say
someone is using it for network connections which are already
nonblocking, but also needs database or file access.  They can use
threads for the stuff that isn''t yet nonblocking.

Good to see an event framework started for ruby, it definitely needed one.