foreach (keys %plugins) {
my $thread_queue = Thread::Queue::Any->new;
my @thread_subs;
$plugins{$_}->SUBS_AS_THREADS(\@thread_subs, $thread_queue);
foreach my $sub (@thread_subs) {
async { $sub->($plugins{$_}, \%plugins, $thread_queue, $mw) };
}
}
...
...
MainLoop;
####
sub _thread_sub_in_a_plugin {
my $self = shift;
my $plugins_ref = shift;
my $thread_queue = shift;
my $mw = shift;
#$self->{'thread_queue'} = $thread_queue;
$$plugins_ref{'imagePlugin'}->{'thread_queue'} = $thread_queue;
# The 2 above same thing, really...
while (1) {
my ($full_path) = $thread_queue->dequeue;
...
}
}
####
Main(Tk) imagePlugin
|
|
|------------*
| |
| generate and show image
|
|