Thread::Channel - Fast thread queues
version 0.003
use threads; use Thread::Channel; my $channel = Thread::Channel->new; my $reader = threads->create(sub { while (my $line = <>) { $channel->enqueue($line) }; $channel->enqueue(undef); }); while (defined(my $line = $channel->dequeue)) { print $line; } $reader->join;
Thread::Channel is an alternative to Thread::Queue. By using a smart serialization ladder, it can achieve high performance without compromizing on flexibility.
This constructs a new channel.
This enqueues the message @items to the channel. Note that this list is a single message.
@items
Dequeues a message from queue. Note that this returns a list, not (necessarily) a scalar. If the channel is empty, it will wait until a message arrives.
Dequeues a message from queue. Note that this returns a list, not (necessarily) a scalar. If the channel is empty, it will return an empty list.
Thread::Queue
Sereal
Leon Timmermans <fawaka@gmail.com>
This software is copyright (c) 2009 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Thread::Channel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Thread::Channel
CPAN shell
perl -MCPAN -e shell install Thread::Channel
For more information on module installation, please visit the detailed CPAN module installation guide.