implication of nesting coroutines

Marc Lehmann schmorp at schmorp.de
Sat Jul 6 06:37:09 CEST 2013


On Sat, Jul 06, 2013 at 11:58:44AM +0800, Michael Fung <mike at 3open.org> wrote:
> I want to use MongoDB::Async, which claims: "This driver uses Coro
> and EV. It switches to another Coro thread while waiting response
> from server."
> 
> If I use it like that:
> [code]
> # coro thread to read database per user request
> async {
>   while (1) {
>   ...
>   my $wait_user_request = AnyEvent->io(
>     ...
>     cb => rouse_cb
>   );
> 
>   $res = rouse_wait;
>   # Use MongoDB::Async here to read database ...
>   ...
>   }
> }
> [/code]
> 
> 
> So, this means nesting coroutines, right? If yes, is it bad practice?

Hmm, what exactly do you mean with nesting? I see nothing in your example
that would count as nesting to me.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list