implication of nesting coroutines
Michael Fung
mike at 3open.org
Sat Jul 6 07:19:57 CEST 2013
MongoDB::Async claims to use Coro, I suppose that means it will have an
async block somewhere in the read routine. To simplify the case:
[code]
async {
...
db_read();
}
sub db_read() {
async {
...
}
}
[/code]
This is nesting I am afraid?
Rgds,
Michael
On 7/6/2013 12:37 PM, Marc Lehmann wrote:
> 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.
>
More information about the anyevent
mailing list