The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Shared::Queue - Perl extension for shared queue over mmap-ed file

SYNOPSIS

        use Shared::Queue;
        my $q = new Shared::Queue(
                file=> "file.dat",
                queue => 10,
                length => 20,
        );
        unless($q->push("abcdefghijklmnopqrstuvwxyz")){
                die "fail push";
        }

        print "length of queue is ",$q->length,"\n";

        while(defined(my $v = $q->pop)){
                print $v,"\n";
        }
        print "no data\n";

DESCRIPTION

Shared::Queue - Shared circled 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. If pushed data has size greater that capacity push has return undef. Tested only on linux.

Length of record align for 4 bytes. Length of file align for 4k.

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.