On Sun Jan 22 21:05:57 2012, TJC wrote:
Show quoted text> I know it can't use the callback style of API calls, but couldn't it
use
Show quoted text> the method whereby it waits on its own CondVar to complete, then
returns
Show quoted text> the value of that?
>
> Essentially, doing this, but internally:
>
> my $cv = AnyEvent->cv;
> $client->get ($key, $cv);
> my $value = $cv->recv;
That might work if you were using Coro as well, but without Coro, you
can't have more than one CondVar doing ->recv at once. If Twiggy is
doing one, then if M::C does ->recv, it will try to enter the event loop
recursively and everything explodes.
So while I agree it would be great if this could be done somehow, I
really don't see any way to make it happen, at least not without
rewriting M::C's interface in its entirety to use something like
deferreds/promises and dispensing with the idea of offerring separate
sync/async interfaces entirely.
I do will point out, though, that Twiggy is *not* the default web server
layer for Plack; in fact it is a specialized back-end for writing non-
blocking asynchronous code, and if you're expecting code to be used
under Twiggy, you need to write it in a callback style.