Queue::Mmap

Perl extension for shared queue over mmap-ed file
Download

Queue::Mmap Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Publisher Name:
  • Ildar Efremov
  • Publisher web site:
  • http://search.cpan.org/~iefremov/

Queue::Mmap Tags


Queue::Mmap Description

Perl extension for shared queue over mmap-ed file Queue::Mmap is a 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 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) mod => 0666, # make mode for file );push $string push $string into queue with block return false on failure return ($time_spend,$time_wait_lock) in array context return $time_spend in scalar contextpop poped top value from queue with block return C< undef > on empty queuetop copy top value from queue without block return C< undef > on empty queuedrop drop top value from queue with blocklength return number of records in queuestat return array top - index top records bottom - index last records que_len - capacity of queue rec_len - lenth one recordaligments Length of record align for 4 bytes. Length of file align for 4k.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) mod => 0666, # make mode for file ); unless($q->push("abcdefghijklmnopqrstuvwxyz")){ die "fail push"; } my $w = $q->push("abcdefghijk"); printf "%.6f\n",$w; my ($t,$l) = $q->push("abcdefghijk"); printf "total = %.6f, wait lock %.6f\n",$t,$l; 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"; Requirements: · Perl


Queue::Mmap Related Software