A while back, MCE::Hobo spawned children on the Windows platform until recently, now threads. Hence, one might want the thread-id in the output. There is no "wait" equivalent for threads. Therefore, MCE::Hobo->waitone is not yet optimized on Windows. Other MCE::Hobo methods are fine.
use strict; use warnings; use if $^O eq 'MSWin32', 'threads'; use Time::HiRes 'time'; use MCE::Hobo; my $tid = 0; sub CLONE { $tid = threads->tid() if $INC{'threads.pm'}; } sub mhobo ($$&) { my ($count, $max, $code) = @_; foreach my $c (1 .. $count) { MCE::Hobo->waitone() unless $c <= $max; exit(255) unless defined (my $h = MCE::Hobo->create($code, $c) +); } MCE::Hobo->waitall(); } my $start = time; mhobo(12, 4, sub { my $x = 1e8; $x-- while $x; print "$$.$tid\n"; }); printf "Seconds: %0.03f\n", time - $start;
Please know that MCE::Hobo was an exercise for a threads-like or forks-like companion to MCE::Shared.
Regards, Mario.
In reply to Re^2: Enlighten by Abigail-II's example. Tis a MCE::Hobo demonstration.
by marioroy
in thread Enlighten by Abigail-II's example. Tis a MCE::Hobo demonstration.
by marioroy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |