Padre::Service(3) persistent Padre::Task API


# Create your service, default implementation warns to output
# sleeps 1 second and loops over.
my $service = Padre::Service->new();
$main , -1 , $service->event ,
# Later
$service->shutdown; # Your show_my_dialog will be called...,eventually


Padre::Service extends Padre::Task to provide a means to launch and control a long running background service, without blocking the editor.


To extend this class, inherit it and implement "service_loop" and preferably "hangup".

"service_loop" should not block forever. If there is no work for the service to do then return immediately, allowing the "Task->run" loop to continue.

  package Padre::Service::HTTPD
  use base qw( Padre::Service );
  sub prepare { # Build a dummy httpd.conf from $self , "BREAK" if error }
  sub service_start { # Launch httpd binary goodness, IPC::Run3 maybe? }
  sub service_shutdown { # Clean shutdown httpd binary }
  sub service_loop { # ->select($timeout) on your IPC handles }
  sub hangup { ->service_shutdown ?!?}
  sub terminate { # Stop everything, brutally }



Overrides "Padre::Task::run" providing a non-blocking loop around the "TaskManager" to "Service" shared queue.

"run" will call "hangup" or "terminate" on your service if instructed by the main thread, otherwise "service_loop" is called in void context with no arguments in a tight loop.


consider start the background_thread analog of "prepare" and will be called in the service thread immediately prior to the service loop starting.


Called on your service when the editor requests a hangup. Your service is obliged to gracefully stop what it is doing and return from this method as soon as possible


Called on your service when "TaskManager" believes your service is hung or not responding to a "<-"hangup>. Your service is obliged to IMMEDIATELY stop everything and to hell with the consequences.


Called in a loop while the service is believed to be running The default implementation emits output to the editor and sleeps for a second before returning control to the loop.


Accessor for this service's instance event, in the running service data may be posted to this event and the Wx subscribers will be notified


accessor for the shared queue the service thread is polling for input. Calling "enqueue" on reference sends data to the service thread. Storable serialization rules apply. See also ``event'' for receiving data from the service thread


Accepts a reference as it's argument, this is serialized and sent to the service thread


Copyright 2008-2010 The Padre development team as listed in

This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.