Thread::Queue::Monitored

Monitor a queue for specific content
Download

Thread::Queue::Monitored Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Elizabeth Mattijsen
  • Publisher web site:
  • http://search.cpan.org/~elizabeth/

Thread::Queue::Monitored Tags


Thread::Queue::Monitored Description

Thread::Queue::Monitored is a Perl module that only functions on threaded Perl or an unthreaded perl with the "forks" module installed.A queue, as implemented by Thread::Queue::Monitored is a thread-safe data structure that inherits from Thread::Queue. But unlike the standard Thread::Queue, it starts a single thread that monitors the contents of the queue by taking new values off the queue as they become available.It can be used for simply logging actions that are placed on the queue. Or only output warnings if a certain value is encountered. Or whatever.The action performed in the thread, is determined by a name or reference to a subroutine. This subroutine is called for every value obtained from the queue.Any number of threads can safely add elements to the end of the list.SYNOPSIS use Thread::Queue::Monitored; my ($q,$t) = Thread::Queue::Monitored->new( { monitor => sub { print "monitoring value $_\n" }, # is a must pre => sub { print "prepare monitoring\n" }, # optional post => sub { print "stop monitoring\n" }, # optional queue => $queue, # use existing queue, create new if not specified exit => 'exit', # default to undef } ); $q->enqueue("foo"); $q->enqueue(undef); # exit value by default @post= $t->join; # optional, wait for monitor thread to end $queue= Thread::Queue::Monitored->self; # "pre", "do", "post" onlyProduct's homepage


Thread::Queue::Monitored Related Software