PoCo::JobQueue skeleton

use POE qw( Session Component::JobQueue ); ### The queue processing session POE::Session->create( inline_states => { _start => \&start_queue, acquire_jobs => \&acquire_jobs, enqueue_job => \&enqueue_job, finish_job => \&finish_job, } ); ### The actual queue POE::Component::JobQueue->spawn( Alias => 'MyQueue', WorkerLimit => 4, Worker => sub { my ( $postback, $job ) = @_; my @results = process_job( $job ); $postback->(@results); }, Passive => {}, ); # Main event loop POE::Kernel->run(); # session states sub start_queue { $_[KERNEL]->yield('acquire_jobs'); } sub acquire_jobs { # implement some way to receive jobs. # here i'm going to pretend i can poll some resource # and loop indefinitely if( my $job = poll_resource() ) { $_[KERNEL]->yield( enqueue_job => $job ); } # poll again in 10 seconds $_[KERNEL]->delay_add( acquire_jobs => 10 ); } sub enqueue_job { my ($job) = @_[ ARG0 ]; # this will enqueue the job on the job queue $_[KERNEL]->post( MyQueue => 'enqueue', 'finish_job', # our event on completion $job ); } sub finish_job { my ( $request_packet, $response_packet ) = @_[ ARG0, ARG1 ]; my ($job) = @{$request_packet}; # original post/fetch my @job_results = @{$response_packet}; # passed from the postba +ck # do cleanup } ### example our $p = 0; sub poll_resource { ++$p } sub process_job { my $job = shift; print "I got job $job\n" } __END__
[download]

Programming hurdles

From "The elephant in the room", Richard Bornat and Saeed Dehnadi, School of Computing Science, Middlesex University (presentation slides" (in PDF))

CPAN shell - list of issues/quirks/gripes

Someone asked me to keep a list of things that might be improved about the cpan shell. So I'm keeping that here.