syphilis has asked for the wisdom of the Perl Monks concerning the following question:
I'm seeking information that doesn't pre-suppose that the reader is threads-savvy. Just a simple "how to" (if such exists) would be best .... anything more detailed would quite likely be lost on me :-)use threads; use warnings; use Math::GMP; $th1 = threads->new(\&start_thread1, '123' x 11); $ret1 = $th1->join(); if(ref($ret1) eq 'Math::GMP') { print "\$ret1 => ", ref($ret1), " ", Math::GMP::get_str_gmp($ret1, 1 +0), "\n"; } sub start_thread1 { my $mbi = Math::GMP->new($_[0]); return $mbi; }
But then - if I so much as load Math::Pari then that script, too, segfaults. Does that indicate that Math::BigInt is *not* threadsafe ? Or does it merely indicate that one ought not to load Math::Pari in a script that invloves threading ?use threads; use warnings; #use Math::Pari; use Math::BigInt; $th1 = threads->new(\&start_thread1, '123' x 11); $ret1 = $th1->join(); print $ret1, "\n"; sub start_thread1 { my $mbi = Math::BigInt->new($_[0]); return $mbi; } __END__ Outputs: 123123123123123123123123123123123
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing threadsafe perl extensions
by BrowserUk (Patriarch) on Oct 21, 2007 at 12:40 UTC | |
by syphilis (Archbishop) on Oct 21, 2007 at 13:47 UTC | |
by BrowserUk (Patriarch) on Oct 21, 2007 at 15:15 UTC | |
by syphilis (Archbishop) on Oct 21, 2007 at 23:48 UTC | |
by BrowserUk (Patriarch) on Oct 22, 2007 at 00:01 UTC | |
| |
|
Re: Writing threadsafe perl extensions
by shmem (Chancellor) on Oct 21, 2007 at 08:37 UTC | |
|
Re: Writing threadsafe perl extensions
by lorn (Monk) on Oct 22, 2007 at 15:03 UTC |