++ed by:
RSHADOW KRAUTCAT FARACO ASB DELON

33 PAUSE users
34 non-PAUSE users.

Marc A. Lehmann

NAME

Coro::Event - do events the coro-way

SYNOPSIS

 use Coro;
 use Coro::Event;

 sub keyboard : Coro {
    my $w = Coro::Event->io(fd => *STDIN, poll => 'r');
    while() {
       print "cmd> ";
       my $ev = $w->next; my $cmd = <STDIN>;
       unloop unless $cmd ne "";
       print "data> ";
       my $ev = $w->next; my $data = <STDIN>;
    }
 }

 &loop;

DESCRIPTION

This module enables you to create programs using the powerful Event modell (and module), while retaining the linear style known from simple or threaded programs.

This module provides a method and a function for every watcher type (flavour) (see Event). The only difference between these and the watcher constructors from Event is that you do not specify a callback function - it will be managed by this module.

Your application should just create all necessary coroutines and then call Coro::Event->main.

$w = Coro::Event->flavour(args...)

Create and return a watcher of the given type.

Examples:

  my $reader = Coro::Event->io(fd => $filehandle, poll => 'r');
  $reader->next;
$w->next

Return the next event of the event queue of the watcher.

do_flavour(args...)

Create a watcher of the given type and immediately call it's next method. This is less efficient then calling the constructor once and the next method often, but it does save typing sometimes.

$result = loop([$timeout])

This is the version of loop you should use instead of Event::loop when using this module - it will ensure correct scheduling in the presence of events.

unloop([$result])

Same as Event::unloop (provided here for your convinience only).

BUGS

This module is implemented straightforward using Coro::Channel and thus not as efficient as possible.

AUTHOR

 Marc Lehmann <pcg@goof.com>
 http://www.goof.com/pcg/marc/

1 POD Error

The following errors were encountered while parsing the POD:

Around line 145:

You forgot a '=back' before '=head1'