summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/threads/shared.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/threads/shared.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/threads/shared.pm43
1 files changed, 36 insertions, 7 deletions
diff --git a/Master/tlpkg/tlperl/lib/threads/shared.pm b/Master/tlpkg/tlperl/lib/threads/shared.pm
index d4d62b22c70..ecbc1fd1db8 100644
--- a/Master/tlpkg/tlperl/lib/threads/shared.pm
+++ b/Master/tlpkg/tlperl/lib/threads/shared.pm
@@ -7,13 +7,16 @@ use warnings;
use Scalar::Util qw(reftype refaddr blessed);
-our $VERSION = '1.40';
+our $VERSION = '1.43';
my $XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
# Declare that we have been loaded
$threads::shared::threads_shared = 1;
+# Method of complaint about things we can't clone
+$threads::shared::clone_warn = undef;
+
# Load the XS code, if applicable
if ($threads::threads) {
require XSLoader;
@@ -156,7 +159,12 @@ $make_shared = sub {
} else {
require Carp;
- Carp::croak("Unsupported ref type: ", $ref_type);
+ if (! defined($threads::shared::clone_warn)) {
+ Carp::croak("Unsupported ref type: ", $ref_type);
+ } elsif ($threads::shared::clone_warn) {
+ Carp::carp("Unsupported ref type: ", $ref_type);
+ }
+ return undef;
}
# If input item is an object, then bless the copy into the same class
@@ -187,7 +195,7 @@ threads::shared - Perl extension for sharing data structures between threads
=head1 VERSION
-This document describes threads::shared version 1.40
+This document describes threads::shared version 1.43
=head1 SYNOPSIS
@@ -311,6 +319,19 @@ For cloning empty array or hash refs, the following may also be used:
$var = &share([]); # Same as $var = shared_clone([]);
$var = &share({}); # Same as $var = shared_clone({});
+Not all Perl data types can be cloned (e.g., globs, code refs). By default,
+C<shared_clone> will L<croak|Carp> if it encounters such items. To change
+this behaviour to a warning, then set the following:
+
+ $threads::shared::clone_warn = 1;
+
+In this case, C<undef> will be substituted for the item to be cloned. If
+set to zero:
+
+ $threads::shared::clone_warn = 0;
+
+then the C<undef> substitution will be performed silently.
+
=item is_shared VARIABLE
C<is_shared> checks if the specified variable is shared or not. If shared,
@@ -383,10 +404,10 @@ L<Thread::Semaphore>.
The C<cond_wait> function takes a B<locked> variable as a parameter, unlocks
the variable, and blocks until another thread does a C<cond_signal> or
C<cond_broadcast> for that same locked variable. The variable that
-C<cond_wait> blocked on is relocked after the C<cond_wait> is satisfied. If
+C<cond_wait> blocked on is re-locked after the C<cond_wait> is satisfied. If
there are multiple threads C<cond_wait>ing on the same variable, all but one
will re-block waiting to reacquire the lock on the variable. (So if you're only
-using C<cond_wait> for synchronisation, give up the lock as soon as possible).
+using C<cond_wait> for synchronization, give up the lock as soon as possible).
The two actions of unlocking the variable and entering the blocked wait state
are atomic, the two actions of exiting from the blocked wait state and
re-locking the variable are not.
@@ -408,7 +429,8 @@ drops to zero:
=item cond_timedwait CONDVAR, ABS_TIMEOUT, LOCKVAR
In its two-argument form, C<cond_timedwait> takes a B<locked> variable and an
-absolute timeout as parameters, unlocks the variable, and blocks until the
+absolute timeout in I<epoch> seconds (see L<time() in perlfunc|perlfunc/time>
+for more) as parameters, unlocks the variable, and blocks until the
timeout is reached or another thread signals the variable. A false value is
returned if the timeout is reached, and a true value otherwise. In either
case, the variable is re-locked upon return.
@@ -543,7 +565,7 @@ C<share()> allows you to C<< share($hashref->{key}) >> and
C<< share($arrayref->[idx]) >> without giving any error message. But the
C<< $hashref->{key} >> or C<< $arrayref->[idx] >> is B<not> shared, causing
the error "lock can only be used on shared values" to occur when you attempt
-to C<< lock($hasref->{key}) >> or C<< lock($arrayref->[idx]) >> in another
+to C<< lock($hashref->{key}) >> or C<< lock($arrayref->[idx]) >> in another
thread.
Using L<refaddr()|Scalar::Util/"refaddr EXPR">) is unreliable for testing
@@ -585,6 +607,13 @@ Either of the following will work instead:
...
}
+This module supports dual-valued variables created using L<dualvar() from
+Scalar::Util|Scalar::Util/"dualvar NUM, STRING">). However, while C<$!> acts
+like a dualvar, it is implemented as a tied SV. To propagate its value, use
+the follow construct, if needed:
+
+ my $errno :shared = dualvar($!,$!);
+
View existing bug reports at, and submit any new bugs, problems, patches, etc.
to: L<http://rt.cpan.org/Public/Dist/Display.html?Name=threads-shared>