For shared objects, the OO interface has the least overhead. MCE::Shared provides on-demand dereferencing for array and hash-like behavior. In that case, a mutex is needed whenever dereferencing involves a fetch and store (equals 2 IPC trips to the shared-manager). Regarding the OO interface, there is a single entry point to the shared-manager process. This is why a mutex isn't needed when accessing shared objects via the OO interface, unless wanting a mutex around updating two or more shared objects.
sub task {
our $mutex;
$mutex->lock; # not necessary when accessing shared-objects via th
+e OO interface
$result->push(shift);
$mutex->unlock;
$mutex->lock; # necessary if dereferencing involves fetch and stor
+e behind TIE
push @{ $result }, shift;
$mutex->unlock;
}
-
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.
|