IPC::DirQueue::Job - an IPC::DirQueue task
my $dq = IPC::DirQueue->new({ dir => "/path/to/queue" });
my $job = $dq->pickup_queued_job();
open(IN, "<".$job->get_data_path());
my $str = <IN>;
# ...
close IN;
$job->finish();
# or...
my $data = $job->get_data();
$job->finish();
A job object returned by "IPC::DirQueue". This
class provides various methods to access job information, and report job
progress and completion.
Any submitted metadata can be accessed through the
"$job->{metadata}" hash reference. For
example:
print "email: ", $job->{metadata}->{submitter_email}, "\n";
Otherwise, you can access the queued data file using
"get_data_path()", or directly as a string
using "get_data()".
- $data = $job->get_data();
- Return the job's data. The return value will be a string, the data that
was originally enqueued for this job.
- $path = $job->get_data_path();
- Return the full path to the task's data file. This can be opened and read
safely while the job is active.
- $nbytes = $job->get_data_size_bytes();
- Retrieve the size of the data without performing a
"stat" operation.
- $secs = $job->get_time_submitted_secs();
- Get the seconds-since-epoch (in other words, the
"time_t") on the submitting host when
this task was submitted.
- $usecs = $job->get_time_submitted_usecs();
- Get the microseconds within that second, as measured by
"gettimeofday" on the submitting host,
when this task was submitted.
- $hostname = $job->get_hostname_submitted();
- Get the name of the submitting host where this task originated.
- $job->touch_active_lock();
- Update the lockfile to reflect that this task is still being processed. If
a task has been active, but the lockfile has not been touched for more
than 600 seconds, another
"IPC::DirQueue" queue processor may take
it over.
- $job->finish();
- Report that the job has been completed, and may be removed from the
queue.
- $job->return_to_queue();
- Return the job to the queue, unfinished. Another task processor may then
pick it up.