NAME
Queue::Mmap - Perl extension for shared queue over mmap-ed file
SYNOPSIS
use Queue::Mmap;
my $q = new Queue::Mmap(
file => "file.dat",
queue => 10, # length of queue
length => 20, # length one record (if data longer record, data placed in some records)
);
unless($q->push("abcdefghijklmnopqrstuvwxyz")){
die "fail push";
}
print "length of queue is ",$q->length,"\n";
my $top = $q->top;
while(defined(my $v = $q->pop)){
print $v,"\n";
}
print "no data\n";
DESCRIPTION
Queue::Mmap - Shared circle-queue over mmap-ed file.
Usefull for multy process task queue. One process(es) push task message, and other process(es) pop and execute that tasks. Access with locking(fcntl) guaranted right order without conflict. If pushed data has size greater that record len data placed in some records. If pushed data has size greater that capacity (record * queue) push has return undef.
- new %params
-
Create new queue object
- push $string
-
push $string into queue with block return false on failure
- pop
-
poped top value from queue with block return
undef
on empty queue - top
-
copy top value from queue without block return
undef
on empty queue - drop
-
drop top value from queue with block return
undef
on failfure - length
-
return number of records in queue
- stat
-
return array top - index top records bottom - index last records que_len - capacity of queue rec_len - lenth one record
- aligments
-
Length of record align for 4 bytes. Length of file align for 4k.
TODO
Tested only on linux.
EXPORT
None by default.
SEE ALSO
AUTHOR
Ildar Efremov, <iefremov@2reallife.com<gt>
COPYRIGHT AND LICENSE
Copyright (C) 2010 by Ildar Efremov
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 100:
'=item' outside of any '=over'
- Around line 143:
You forgot a '=back' before '=head1'