Hi karlgoethebier,
I want to share an optimization for extracting the results from the shared-manager. Iterating and fetching keys individually from a shared-hash is not necessary after running parallel.
my $iter = $shared->iterator();
my $result;
while ( my ( $url, $data ) = $iter->() ) {
$result->{$url} = $data;
}
$result;
All that IPC behind the scene may be reduced to a single call.
# export to a non-shared MCE::Shared::Hash object
my $result = $shared->export( );
# or simply return an unblessed hash
return $shared->export( { unbless => 1 } );
# or export-destroy the shared object from the shared-manager
# because, the shared hash isn't needed once parallel is completed
return $shared->destroy( { unbless => 1 } );
Our fellow brother 1nickt is who requested for the unbless option. Thank you, 1nickt.
Regards, Mario
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|