Linux::Perl::mq - POSIX message queue
my $mq = Linux::Perl::mq->new( name => 'my_message_queue', flags => ['CREAT'], # Only needed for message creation: msgsize => 16, maxmsg => 5, mode => 0644, ); $mq->send( msg => 'Hello, world!' ); my $got_msg = $mq->receive( msgsize => 16 ); $mq->blocking(0); # sets non-blocking mode $mq->blocking(); # returns 0 my $attrs_hr = $mq->getattr(); # For select, epoll, or poll: my $fileno = $mq->fileno();
Returns truthy if a queue is removed or falsy if no queue with the given $NAME exists.
Throws an exception on failure.
Creates a new read/write message queue object.
%OPTS are:
name
flags - Any/all/none of: CLOEXEC, NONBLOCK, CREAT, EXCL.
flags
CLOEXEC
NONBLOCK
CREAT
EXCL
mode - Only relevant if the CREAT flag is given.
mode
maxmsg - Only relevant if the CREAT flag is given.
maxmsg
msgsize - Only relevant if the CREAT flag is given.
msgsize
Like new(), but the queue handle is write-only.
new()
Like new(), but the queue handle is read-only.
Returns the file descriptor number. This is useful, e.g., for use with select, epoll, or poll.
Returns a hashref of attributes that corresponds to struct mq_attr. See man 3 mq_getattr for details.
struct mq_attr
man 3 mq_getattr
Imitates IO::Handle’s method of the same name. Returns a boolean that indicates whether the message queue handle is blocking.
Sets the message queue handle as blocking or non-blocking.
Sends a message to the queue. An exception is thrown on failure, e.g., if the queue cannot accommodate another message.
msg - The message to send.
msg
prio - Optional, the message priority. Defaults to 0 (highest priority).
prio
timeout - Optional, in seconds. (Can be fractional.)
timeout
Attempts to slurp a message from the queue.
$BUFFER is a pre-initialized buffer where the message will be stored. It must be at least as long as the message queue’s msgsize.
prio - Optional, the receive priority. Defaults to 0 (highest priority).
Returns the message length on success; if there is no message available, undef is returned. Any other failure prompts an exception.
To install Linux::Perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::Perl
CPAN shell
perl -MCPAN -e shell install Linux::Perl
For more information on module installation, please visit the detailed CPAN module installation guide.