资 源 简 介
Extend your threaded Perl objects with this event-bus which brokers requests via autoloader calls.
This is an easy way of exposing a Perl object to thread calls via autoloader & opportunistic shared cloning and serialisation of parameters/return values. It takes some of the pain of Perl threading away.
Example use:
```
#!/usr/bin/perl
package WorkerThread;
use threads;
use threads::shared;
use Thread::EventBus;
sub new
{
my $class = shift;
my $id = shift;
my $self = {};
bless $self, $class;
$self->{ "eb" } = Thread::EventBus->new( $self, "worker#" . $id );
$self->{ "eb" }->set_procedure( "method1", &method1 );
$self->{ "eb" }->set_method( "method2", &method2 );
$self->{ "id" } = $id;
$self->thread_start;
return $self;
}
sub thread_start
{
my $self = shift;
threads->create( &threadloop, $self );
return;
}