Why would you not use Thread::Conveyor?
Because I know better. Why are you suggesting it when you obviously do not?
I was asked to update this to explain my reasoning, so here it is:
Thread::Conveyor doesn't work. It isn't thread-safe.
Don't believe me, try it for yourself! I'll even provide the test script for you:
#! perl -slw
use strict;
use threads ( stack_size => 4096 );
use Thread::Conveyor;
my $belt = Thread::Conveyor->new( {
maxboxes => 50,
minboxes => 25,
optimize => 'memory', # or 'cpu'
});
async{
print while defined( $_ = $belt->take );
}->detach;
$belt->put( $_ ) for 1 .. 10;
$belt->put( undef );
Nine times out of ten this will segfault with;
Problem signature:
Problem Event Name: APPCRASH
Application Name: perl.exe
Application Version: 5.10.1.1007
Application Timestamp: 4b60ba96
Fault Module Name: perl510.dll
Fault Module Version: 5.10.1.1007
Fault Module Timestamp: 4b60ba95
Exception Code: c0000005
Exception Offset: 000000000006c6f8
OS Version: 6.0.6001.2.1.0.768.3
Locale ID: 2057
Additional Information 1: 90e0
Additional Information 2: e939a93db866b76af40148e39e07fd0d
Additional Information 3: 85c4
Additional Information 4: 6c632c487ffa8e4b9b7137dbbbe72313
On the 10th occasion it will emit the following before hanging:
C:\test>t-TCcrap
1
2
3
4
5
6
7
8
Thread 1 terminated abnormally: Can't use an undefined value as an ARR
+AY reference at C:/Perl64/site/lib/Thread/Tie/Array.pm (loaded on dem
+and from offset 1939 for 176 bytes) line 75.
Terminating on signal SIGINT(2)
And if you trace the run you get:
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.