| AnyEvent-Subprocess documentation | Contained in the AnyEvent-Subprocess distribution. |
AnyEvent::Subprocess::Running::Delegate - delegate on the running process class
version 1.102912
Delegates must implement these methods:
Return a list of events that need to be sent before the run will be considered complete
Return a list of delegates to be passed to the "done" instance.
Called after all events are received but before calling the final
on_complete method.
Returns the event sender coderef for the event named $name.
$name should have been returned by build_events, otherwise this
will break.
Method that works like calling the coderef returned by
event_sender_for($name).
Jonathan Rockway <jrockway@cpan.org>
This software is copyright (c) 2011 by Jonathan Rockway.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| AnyEvent-Subprocess documentation | Contained in the AnyEvent-Subprocess distribution. |
package AnyEvent::Subprocess::Running::Delegate; BEGIN { $AnyEvent::Subprocess::Running::Delegate::VERSION = '1.102912'; } # ABSTRACT: delegate on the running process class use Moose::Role; with 'AnyEvent::Subprocess::Delegate'; has 'event_senders' => ( is => 'rw', isa => 'HashRef', predicate => 'has_event_senders', ); # you can call this before event_senders are vivified sub event_sender_for { my ($self, $event) = @_; return sub { my $val = shift; $self->send_event($event, $val); } } sub send_event { my ($self, $event, $value) = @_; confess "No event senders set yet!" unless $self->has_event_senders; my $sender = $self->event_senders->{$event}; confess "No event sender '$event' found" unless $sender && ref $sender; $sender->($value); return; } requires 'build_events'; requires 'build_done_delegates'; requires 'completion_hook'; 1;
__END__