in reply to Re: Threads From Hell #3: Missing Some Basic Prerequisites
in thread Threads From Hell #3: Missing Some Basic Prerequisites [Solved]
"I cannot make any connection between this post and the earlier 2 in the series"
Sorry BrowserUK for being imprecise, i'll try to give some more information:
Short time ago i wrote a script for learning purposes and fun that renders a huge image (20 MP) in ~13m on my box
I'd like to write a multithreaded version of this script.
The basic idea is to do it "row by row".
Enqueue some rows of the image and process them...
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
...next step...
x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
...proceed until finished.
The snippet in my OP calculates the coordinates for the rows.
For $width = 4; $height = 4; $qsize = 4; the output is:
[ [[0, 0], [0, 1], [0, 2], [0, 3]], [[1, 0], [1, 1], [1, 2], [1, 3]], [[2, 0], [2, 1], [2, 2], [2, 3]], [[3, 0], [3, 1], [3, 2], [3, 3]], ]
@queue should perhaps better been named @rows.
Then:
my $queue = Thread::Queue->new(); $queue->enqueue(\@rows); my @threads = map { threads->create( \&process, $queue ); } 1 .. 4; ...
Somewhere in the code:
if ( $div == 0 ) { $image->setpixel( x => $x, y => $y, color => $black ); } else { $image->setpixel( x => $x, y => $y, color => $palette[$color] ); }
OK, busted. It's a Mandelbrot. My first try.
I hope very much that i could clarify the connection of my OP to the series.
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
---|