in reply to Re^6: while reading a file, transfer the same data to two different processes.
in thread while reading a file, transfer the same data to two different processes.
Interesting, thank you Almut.
If you have time & inclination, I've one final line of enquiry:
use strict; use warnings; use threads; my $str = 'x' x 32_000_000; sub fork_wait { my $pid = fork; if ($pid) { wait; } else { substr( $str, $_, 1 ) &= ~ ' ' for 0 .. length( $str ) -1; exit 0; } } sub create_thread_join { threads->create( sub { substr( $str, $_, 1 ) &= ~ ' ' for 0 .. length( $str ) -1; } )->join; } use Benchmark qw( cmpthese ); cmpthese - 3, { Forks => \&fork_wait, Threads => \&create_thread_join, };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: while reading a file, transfer the same data to two different processes.
by almut (Canon) on May 21, 2010 at 02:02 UTC | |
by BrowserUk (Patriarch) on May 21, 2010 at 09:42 UTC | |
by almut (Canon) on May 21, 2010 at 10:11 UTC | |
by rowdog (Curate) on May 21, 2010 at 11:21 UTC | |
by BrowserUk (Patriarch) on May 21, 2010 at 11:53 UTC |