Async-Template

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

       # default AnyEvent blocker is enabled if no DONE handler is provided
       BLOCKER => sub{ $cv->recv; },

       # done handler - called when template process is finished
       # default event loop and blocker is enabled if DONE is not specified
       # may be redefined at the process() function
       DONE => sub{ my $output = shift; $cv->send; },
    }) || die Async::Template->error();


    # single blocked process

    my $tt = Async::Template->new({}) || die Async::Template->error();
    $tt->process($template, $vars, \$output)


    # nonblocked multiple procesess

    my $cv = AnyEvent->condvar;
    $cv->begin;
    my $tt2 = Async::Template->new({
       DONE => sub{ my $output = shift; $cv->end; },
    }) || die Async::Template->error();
    $cv->begin;
    AnyEvent->timer(after => 10, cb => sub { $cv->end; });
    $cv->recv

lib/Async/Template.pm  view on Meta::CPAN

      # default AnyEvent blocker is enabled if no DONE handler is provided
      BLOCKER => sub{ $cv->recv; },

      # done handler - called when template process is finished
      # default event loop and blocker is enabled if DONE is not specified
      # may be redefined at the process() function
      DONE => sub{ my $output = shift; $cv->send; },
   }) || die Async::Template->error();


   # single blocked process

   my $tt = Async::Template->new({}) || die Async::Template->error();
   $tt->process($template, $vars, \$output)


   # nonblocked multiple procesess

   my $cv = AnyEvent->condvar;
   $cv->begin;
   my $tt2 = Async::Template->new({
      DONE => sub{ my $output = shift; $cv->end; },
   }) || die Async::Template->error();
   $cv->begin;
   AnyEvent->timer(after => 10, cb => sub { $cv->end; });
   $cv->recv



( run in 0.981 second using v1.01-cache-2.11-cpan-49f99fa48dc )