Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Threads From Hell #3: Missing Some Basic Prerequisites

by FreeBeerReekingMonk (Deacon)
on May 31, 2015 at 21:37 UTC ( [id://1128506]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Threads From Hell #3: Missing Some Basic Prerequisites
in thread Threads From Hell #3: Missing Some Basic Prerequisites [Solved]

Blue rectangle over striped pattern (writing to same pixels), threaded. The Rectangle does not survive intact...

#! perl use warnings; use strict; use threads; use Image::Magick; my $image = Image::Magick->new( size => "600x600", ); $image->Read("xc:white"); for my $i (200..400){ async{ my $color = $i % 2 ? '#f00' : '#0f0'; $image->Draw( primitive => 'line', points => "$i,100 $i,500", stroke => $color, ); }->join; async{ my $y = 100 + $i; $image->Draw( primitive => 'line', points => "200,$y 400,$y", stroke => '#00f' ); }->join; } $image->Set(magick=>'gif'); my $blob = $image->ImageToBlob(); open(FH,"> $0.gif")or die "$!\n"; print FH $blob; close FH;

The example in the previous post with and without threading:

Rate threaded non-threaded threaded 1.41/s -- -94% non-threaded 24.7/s 1652% --

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1128506]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found