NAME

POE::Session::YieldCC - POE::Session extension for using continuations

SYNOPSIS

  use POE::Session::YieldCC;

  POE::Session::YieldCC->create(
    inline_states => {
      handler => sub {
	print "before\n";
	my $val = $_[SESSION]->yieldCC('do_async', 123);
	print "after: $val\n";
      },
      do_async => sub {
        my ($cont, $args) = @_[ARG0, ARG1];
        # do something synchronously, passing $cont about
        # when we're ready:
	$cont->("value");
      },
    },
  );
  $poe_kernel->run();

DESCRIPTION

POE::Session::YieldCC extends POE::Session to allow "continuations". A new method on the session object, yieldCC is introduced.

yieldCC takes as arguments a state name (in the current session) and a list of arguments. Control is yield to that state (via POE::Session->yield) passing a "continuation" as ARG0 and the arguments as an array reference in ARG1. yieldCC does not return immediately.

The "continuation" is a anonymous subroutine that when invoked passes control back to where yieldCC was called returning any arguments to the continuation from the yieldCC. Once the original state that called yieldCC finishes control returns to where the continuation was invoked.

Examples can be found in the examples/ directory of the distribution.

THIS MODULE IS EXPERIMENTAL. This means that I wouldn't be surprised if you encountered segfaults, plagues, weird POE errors, memory leaks or other unexpected behaviour.

SEE ALSO

POE, POE::Session, Coro::State

AUTHOR

Benjamin Smith, <bsmith@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Benjamin Smith

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.