threadeventbus
2016-08-23
1 0 0
暂无评分
其他
如何获取积分?
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;
}
perl
event
Threads
Threading
bus
thread
相关源码推荐
modbus
0
0
暂无评分
modbusTcp源码
0
0
暂无评分
金属槽加角孔
0
0
暂无评分
i2c master and slave reference
0
0
暂无评分
Labview Modbus
0
0
暂无评分
暂无评论