Thread::GoChannel - Fast thread queues with go-like semantics
version 0.004
use threads; use Thread::GoChannel; my $channel = Thread::GoChannel->new; my $reader = threads->create(sub { while (my $line = <>) { $channel->send($line) } $channel->close; }); while (defined(my $line = $channel->receive)) { print $line; } $reader->join;
Thread::GoChannel is an alternative to Thread::Queue. By using a smart duplication instead of serialization it can achieve high performance without compromising on flexibility.
This constructs a new channel.
This sends the message $message to the channel. It will wait until there is a receiver.
$message
Received a message from the channel, it will wait until a message arrives, or return undef if the channel is closed.
Closes the channel for further messages.
Thread::Queue
Thread::Channel
Leon Timmermans <fawaka@gmail.com>
This software is copyright (c) 2021 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::GoChannel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Thread::GoChannel
CPAN shell
perl -MCPAN -e shell install Thread::GoChannel
For more information on module installation, please visit the detailed CPAN module installation guide.