New feature: eval code for send/croak with condvar
Marc Lehmann
schmorp at schmorp.de
Fri May 8 22:52:38 CEST 2015
On Wed, May 06, 2015 at 10:29:19AM +0200, David <post at david-zurb.org> wrote:
> my $cv = AE::cv;
> eval {
> do_something_that_might_croak;
> $cv->send(...);
> };
> if ($@) {
> $cv->croak($@);
> }
>
> That ensures to return the result or croak properly by $cv->recv.
Hmm, I would need a lot more w.r.t. documentation and rationale to add this.
for example, why is this useful? Is it a method for consumers or producers?
> Is it possible to add the eval() method to AnyEvent::CondVar? I think
> many others could make profit of it...
I'm not quite convinced of that - can you elaborate in more detail why this
would be so?
Adding such a method would make sense if this is the common way to do
things, or if this is how things *should* be done, but in typical code
(which is very likely event based), you can't put an eval around your
code, so the usefulness of this idiom seems to be limited to special cases
which one perosn might want to code this way, and anotrher in another way.
For example, how would this code be used for e.g. AnyEvent::HTTP if the
callback were a condvar?
--
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