NAME
Forks::Queue::File - file-based implementation of Forks::Queue
VERSION
0.15
SYNOPSIS
my $q = Forks::Queue::File->new( file => "queue-file" );
$q->put( "job1" );
$q->put( { name => "job2", task => "do something", data => [42,19] } );
...
$q->end;
for my $w (1 .. $num_workers) {
if (fork() == 0) {
my $task;
while (defined($task = $q->get)) {
... perform task in child ...
}
exit;
}
}
METHODS
See Forks::Queue for an overview of the methods supported by this Forks::Queue
implementation.
new
$queue = Forks::Queue::File->new( %opts )
$queue = Forks::Queue->new( impl => 'File', %opts )
The Forks::Queue::File
constructor recognized the following configuration options.
file
The name of the file to use to score queue data and metadata. If omitted, a temporary filename is chosen.
It is strongly recommended not to use a file that would reside on an NFS filesystem, since these filesystems have notorious difficulty with synchronizing files across processes.
style
limit
on_limit
join
persist
See "new" in Forks::Queue for descriptions of these options.
debug
Boolean value to enable or disable debugging on this queue, overriding the value in
$Forks::Queue::DEBUG
.dflock
Boolean value to enable directory-based alternative to flock for synchronization of the queue across processeses. The module will often be able to guess whether this flag should be set by default, but it should be used explicitly in some cases such as sharing a queue over processes on different hosts accessing a shared, networked filesystem.
BUGS AND LIMITATIONS
As with anything that requires flock
, you should avoid allowing the queue file to reside on an NFS drive.
LICENSE AND COPYRIGHT
Copyright (c) 2017-2019, Marty O'Brien.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.
See http://dev.perl.org/licenses/ for more information.