Dallaylaen has asked for the wisdom of the Perl Monks concerning the following question:
Suppose I have a number of tasks in one application which may finish in any order. And I need to run some code when all of the tasks have finished. If that matters, the application is running under AnyEvent, but without Coro.
To some extent, AnyEvent's $cv->begin/$cv->end allow what I want. However, I'd like to have more fine-grained control. For instance, I'd like to be unable to "finish" a task twice. Ability to gather data from all tasks would also be nice.
Of course, this can be done. Set up lots of callbacks that share a hash; delete keys from that hash whenever a task finishes; call the megacallback when the hash is empty. I wonder if there's a more civilized way of doing it, maybe some CPAN module?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Callback multiplexer
by Loops (Curate) on Apr 05, 2013 at 13:00 UTC | |
by Dallaylaen (Chaplain) on Apr 05, 2013 at 15:28 UTC | |
by Loops (Curate) on Apr 05, 2013 at 17:09 UTC | |
Re: Callback multiplexer
by Dallaylaen (Chaplain) on Apr 05, 2013 at 07:32 UTC | |
Re: Callback multiplexer
by salva (Canon) on Apr 05, 2013 at 17:46 UTC | |
Re: Callback multiplexer
by Dallaylaen (Chaplain) on Apr 06, 2013 at 20:00 UTC |