in reply to Re^2: Getting started with MCE (the Many-Core Engine)
in thread Getting started with MCE (the Many-Core Engine)
how to adapt this to incrementing strings perl-style
See a a recent example where I showed exactly that, using tie with MCE::Shared (that example shows incrementing the value of keys in a hash; see the MCE::Shared doc for sharing a scalar via tie).
Alternatively, if you are using MCE::Shared's OO interface it provides sugar methods (shown here using MCE::Hobo for workers):
my $shared = MCE::Shared->scalar(0); sub task { $shared->incrby(1); } MCE::Hobo->init( max_workers => 8, posix_exit => 1 ); MCE::Hobo->create( \&task, $_ ) for 0 .. 41; MCE::Hobo->wait_all; END { print "The answer is $shared\n"; }
Hope this helps!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Getting started with MCE (the Many-Core Engine)
by Anonymous Monk on Jun 13, 2018 at 00:18 UTC | |
by marioroy (Prior) on Jun 13, 2018 at 13:37 UTC | |
by Anonymous Monk on Jun 13, 2018 at 15:30 UTC | |
by marioroy (Prior) on Jun 13, 2018 at 20:04 UTC |