When developing (and therefore writing tests and fire-and-forget scripts) for AnyEvent I routinely end up with a boilerplate like this:
my $cv = AnyEvent->condvar; my $timer = AnyEvent->timer( after => 10, cb => sub { $cv->croak("Time +out"); }; do_something( on_success => sub{ $cv->send(@_); }, on_error => sub{ $cv->croak(shift); }, ); my $result = $cv->recv(); undef $timer; analyze_do_something( $result );
I finally got fed up with it and wrote a module (after asking a local mailing list) with the following interface:
my $result = ae_recv { do_something( on_success => ae_send, on_error => ae_croak, ); } 10; # timeout analyze_do_something( $result );
So, my questions would be:

1) Is there such a module already? I haven't found one, but...

2) Is there really a need for such a module?

3) If so, how should I name it? I came up with AnyEvent::AdHoc, but that still isn't clear enough. AnyEvent::Test seems misleading (it's not test-only, and doesn't test AnyEvent itself) and AnyEvent::Simple/Easy seem too broad (besides, AnyEvent doesn't seem easy even with a nice wrapper).

UPDATE: I released the code in question as AE::AdHoc. See http://search.cpan.org/~khedin/AE-AdHoc-0.08/lib/AE/AdHoc.pm

In reply to Simplified API for testing AnyEvent-related code by Dallaylaen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.