Debian Codegraph @

upstream/opensuse-tumbleweed/man3/threads::shared.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "threads::shared 3pm"
61 .TH threads::shared 3pm 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 threads::shared \- Perl extension for sharing data structures between threads
68 .SH VERSION
69 .IX Header "VERSION"
70 This document describes threads::shared version 1.70
71 .SH SYNOPSIS
72 .IX Header "SYNOPSIS"
73 .Vb 2
74 \& use threads;
75 \& use threads::shared;
76 \&
77 \& my $var :shared;
78 \& my %hsh :shared;
79 \& my @ary :shared;
80 \&
81 \& my ($scalar, @array, %hash);
82 \& share($scalar);
83 \& share(@array);
84 \& share(%hash);
85 \&
86 \& $var = $scalar_value;
87 \& $var = $shared_ref_value;
88 \& $var = shared_clone($non_shared_ref_value);
89 \& $var = shared_clone({\*(Aqfoo\*(Aq => [qw/foo bar baz/]});
90 \&
91 \& $hsh{\*(Aqfoo\*(Aq} = $scalar_value;
92 \& $hsh{\*(Aqbar\*(Aq} = $shared_ref_value;
93 \& $hsh{\*(Aqbaz\*(Aq} = shared_clone($non_shared_ref_value);
94 \& $hsh{\*(Aqquz\*(Aq} = shared_clone([1..3]);
95 \&
96 \& $ary[0] = $scalar_value;
97 \& $ary[1] = $shared_ref_value;
98 \& $ary[2] = shared_clone($non_shared_ref_value);
99 \& $ary[3] = shared_clone([ {}, [] ]);
100 \&
101 \& { lock(%hash); ... }
102 \&
103 \& cond_wait($scalar);
104 \& cond_timedwait($scalar, time() + 30);
105 \& cond_broadcast(@array);
106 \& cond_signal(%hash);
107 \&
108 \& my $lockvar :shared;
109 \& # condition var != lock var
110 \& cond_wait($var, $lockvar);
111 \& cond_timedwait($var, time()+30, $lockvar);
112 .Ve
113 .SH DESCRIPTION
114 .IX Header "DESCRIPTION"
115 By default, variables are private to each thread, and each newly created
116 thread gets a private copy of each existing variable. This module allows you
117 to share variables across different threads (and pseudo\-forks on Win32). It
118 is used together with the threads module.
119 .PP
120 This module supports the sharing of the following data types only: scalars
121 and scalar refs, arrays and array refs, and hashes and hash refs.
122 .SH EXPORT
123 .IX Header "EXPORT"
124 The following functions are exported by this module: \f(CW\*(C`share\*(C'\fR,
125 \&\f(CW\*(C`shared_clone\*(C'\fR, \f(CW\*(C`is_shared\*(C'\fR, \f(CW\*(C`cond_wait\*(C'\fR, \f(CW\*(C`cond_timedwait\*(C'\fR, \f(CW\*(C`cond_signal\*(C'\fR
126 and \f(CW\*(C`cond_broadcast\*(C'\fR
127 .PP
128 Note that if this module is imported when threads has not yet been loaded,
129 then these functions all become no\-ops. This makes it possible to write
130 modules that will work in both threaded and non\-threaded environments.
131 .SH FUNCTIONS
132 .IX Header "FUNCTIONS"
133 .IP "share VARIABLE" 4
134 .IX Item "share VARIABLE"
135 \&\f(CW\*(C`share\*(C'\fR takes a variable and marks it as shared:
136 .Sp
137 .Vb 4
138 \& my ($scalar, @array, %hash);
139 \& share($scalar);
140 \& share(@array);
141 \& share(%hash);
142 .Ve
143 .Sp
144 \&\f(CW\*(C`share\*(C'\fR will return the shared rvalue, but always as a reference.
145 .Sp
146 Variables can also be marked as shared at compile time by using the
147 \&\f(CW\*(C`:shared\*(C'\fR attribute:
148 .Sp
149 .Vb 1
150 \& my ($var, %hash, @array) :shared;
151 .Ve
152 .Sp
153 Shared variables can only store scalars, refs of shared variables, or
154 refs of shared data (discussed in next section):
155 .Sp
156 .Vb 2
157 \& my ($var, %hash, @array) :shared;
158 \& my $bork;
159 \&
160 \& # Storing scalars
161 \& $var = 1;
162 \& $hash{\*(Aqfoo\*(Aq} = \*(Aqbar\*(Aq;
163 \& $array[0] = 1.5;
164 \&
165 \& # Storing shared refs
166 \& $var = \e%hash;
167 \& $hash{\*(Aqary\*(Aq} = \e@array;
168 \& $array[1] = \e$var;
169 \&
170 \& # The following are errors:
171 \& # $var = \e$bork; # ref of non\-shared variable
172 \& # $hash{\*(Aqbork\*(Aq} = []; # non\-shared array ref
173 \& # push(@array, { \*(Aqx\*(Aq => 1 }); # non\-shared hash ref
174 .Ve
175 .IP "shared_clone REF" 4
176 .IX Item "shared_clone REF"
177 \&\f(CW\*(C`shared_clone\*(C'\fR takes a reference, and returns a shared version of its
178 argument, performing a deep copy on any non\-shared elements. Any shared
179 elements in the argument are used as is (i.e., they are not cloned).
180 .Sp
181 .Vb 1
182 \& my $cpy = shared_clone({\*(Aqfoo\*(Aq => [qw/foo bar baz/]});
183 .Ve
184 .Sp
185 Object status (i.e., the class an object is blessed into) is also cloned.
186 .Sp
187 .Vb 4
188 \& my $obj = {\*(Aqfoo\*(Aq => [qw/foo bar baz/]};
189 \& bless($obj, \*(AqFoo\*(Aq);
190 \& my $cpy = shared_clone($obj);
191 \& print(ref($cpy), "\en"); # Outputs \*(AqFoo\*(Aq
192 .Ve
193 .Sp
194 For cloning empty array or hash refs, the following may also be used:
195 .Sp
196 .Vb 2
197 \& $var = &share([]); # Same as $var = shared_clone([]);
198 \& $var = &share({}); # Same as $var = shared_clone({});
199 .Ve
200 .Sp
201 Not all Perl data types can be cloned (e.g., globs, code refs). By default,
202 \&\f(CW\*(C`shared_clone\*(C'\fR will croak if it encounters such items. To change
203 this behaviour to a warning, then set the following:
204 .Sp
205 .Vb 1
206 \& $threads::shared::clone_warn = 1;
207 .Ve
208 .Sp
209 In this case, \f(CW\*(C`undef\*(C'\fR will be substituted for the item to be cloned. If
210 set to zero:
211 .Sp
212 .Vb 1
213 \& $threads::shared::clone_warn = 0;
214 .Ve
215 .Sp
216 then the \f(CW\*(C`undef\*(C'\fR substitution will be performed silently.
217 .IP "is_shared VARIABLE" 4
218 .IX Item "is_shared VARIABLE"
219 \&\f(CW\*(C`is_shared\*(C'\fR checks if the specified variable is shared or not. If shared,
220 returns the variable\*(Aqs internal ID (similar to
221 \&\f(CWrefaddr()\fR (see Scalar::Util). Otherwise, returns \f(CW\*(C`undef\*(C'\fR.
222 .Sp
223 .Vb 5
224 \& if (is_shared($var)) {
225 \& print("\e$var is shared\en");
226 \& } else {
227 \& print("\e$var is not shared\en");
228 \& }
229 .Ve
230 .Sp
231 When used on an element of an array or hash, \f(CW\*(C`is_shared\*(C'\fR checks if the
232 specified element belongs to a shared array or hash. (It does not check
233 the contents of that element.)
234 .Sp
235 .Vb 4
236 \& my %hash :shared;
237 \& if (is_shared(%hash)) {
238 \& print("\e%hash is shared\en");
239 \& }
240 \&
241 \& $hash{\*(Aqelem\*(Aq} = 1;
242 \& if (is_shared($hash{\*(Aqelem\*(Aq})) {
243 \& print("\e$hash{\*(Aqelem\*(Aq} is in a shared hash\en");
244 \& }
245 .Ve
246 .IP "lock VARIABLE" 4
247 .IX Item "lock VARIABLE"
248 \&\f(CW\*(C`lock\*(C'\fR places a \fBadvisory\fR lock on a variable until the lock goes out of
249 scope. If the variable is locked by another thread, the \f(CW\*(C`lock\*(C'\fR call will
250 block until it\*(Aqs available. Multiple calls to \f(CW\*(C`lock\*(C'\fR by the same thread from
251 within dynamically nested scopes are safe \-\- the variable will remain locked
252 until the outermost lock on the variable goes out of scope.
253 .Sp
254 \&\f(CW\*(C`lock\*(C'\fR follows references exactly \fIone\fR level:
255 .Sp
256 .Vb 3
257 \& my %hash :shared;
258 \& my $ref = \e%hash;
259 \& lock($ref); # This is equivalent to lock(%hash)
260 .Ve
261 .Sp
262 Note that you cannot explicitly unlock a variable; you can only wait for the
263 lock to go out of scope. This is most easily accomplished by locking the
264 variable inside a block.
265 .Sp
266 .Vb 7
267 \& my $var :shared;
268 \& {
269 \& lock($var);
270 \& # $var is locked from here to the end of the block
271 \& ...
272 \& }
273 \& # $var is now unlocked
274 .Ve
275 .Sp
276 As locks are advisory, they do not prevent data access or modification by
277 another thread that does not itself attempt to obtain a lock on the variable.
278 .Sp
279 You cannot lock the individual elements of a container variable:
280 .Sp
281 .Vb 4
282 \& my %hash :shared;
283 \& $hash{\*(Aqfoo\*(Aq} = \*(Aqbar\*(Aq;
284 \& #lock($hash{\*(Aqfoo\*(Aq}); # Error
285 \& lock(%hash); # Works
286 .Ve
287 .Sp
288 If you need more fine\-grained control over shared variable access, see
289 Thread::Semaphore.
290 .IP "cond_wait VARIABLE" 4
291 .IX Item "cond_wait VARIABLE"
292 .PD 0
293 .IP "cond_wait CONDVAR, LOCKVAR" 4
294 .IX Item "cond_wait CONDVAR, LOCKVAR"
295 .PD
296 The \f(CW\*(C`cond_wait\*(C'\fR function takes a \fBlocked\fR variable as a parameter, unlocks
297 the variable, and blocks until another thread does a \f(CW\*(C`cond_signal\*(C'\fR or
298 \&\f(CW\*(C`cond_broadcast\*(C'\fR for that same locked variable. The variable that
299 \&\f(CW\*(C`cond_wait\*(C'\fR blocked on is re\-locked after the \f(CW\*(C`cond_wait\*(C'\fR is satisfied. If
300 there are multiple threads \f(CW\*(C`cond_wait\*(C'\fRing on the same variable, all but one
301 will re\-block waiting to reacquire the
302 lock on the variable. (So if you\*(Aqre only
303 using \f(CW\*(C`cond_wait\*(C'\fR for synchronization, give up the lock as soon as possible).
304 The two actions of unlocking the variable and entering the blocked wait state
305 are atomic, the two actions of exiting from the blocked wait state and
306 re\-locking the variable are not.
307 .Sp
308 In its second form, \f(CW\*(C`cond_wait\*(C'\fR takes a shared, \fBunlocked\fR variable followed
309 by a shared, \fBlocked\fR variable. The second variable is unlocked and thread
310 execution suspended until another thread signals the first variable.
311 .Sp
312 It is important to note that the variable can be notified even if no thread
313 \&\f(CW\*(C`cond_signal\*(C'\fR or \f(CW\*(C`cond_broadcast\*(C'\fR on the variable. It is therefore
314 important to check the value of the variable and go back to waiting if the
315 requirement is not fulfilled. For example, to pause until a shared counter
316 drops to zero:
317 .Sp
318 .Vb 1
319 \& { lock($counter); cond_wait($counter) until $counter == 0; }
320 .Ve
321 .IP "cond_timedwait VARIABLE, ABS_TIMEOUT" 4
322 .IX Item "cond_timedwait VARIABLE, ABS_TIMEOUT"
323 .PD 0
324 .IP "cond_timedwait CONDVAR, ABS_TIMEOUT, LOCKVAR" 4
325 .IX Item "cond_timedwait CONDVAR, ABS_TIMEOUT, LOCKVAR"
326 .PD
327 In its two\-argument form, \f(CW\*(C`cond_timedwait\*(C'\fR takes a \fBlocked\fR variable and an
328 absolute timeout in \fIepoch\fR seconds (see \fBtime()\fR in perlfunc
329 for more) as parameters, unlocks the variable, and blocks until the
330 timeout is reached or another thread signals the variable. A false value is
331 returned if the timeout is reached, and a true value otherwise. In either
332 case, the variable is re\-locked upon return.
333 .Sp
334 Like \f(CW\*(C`cond_wait\*(C'\fR, this function may take a shared, \fBlocked\fR variable as an
335 additional parameter; in this case the first parameter is an \fBunlocked\fR
336 condition variable protected by a distinct lock variable.
337 .Sp
338 Again like \f(CW\*(C`cond_wait\*(C'\fR, waking up and reacquiring the lock are not atomic,
339 and you should always check your desired condition after this function
340 returns. Since the timeout is an absolute value, however, it does not have to
341 be recalculated with each pass:
342 .Sp
343 .Vb 6
344 \& lock($var);
345 \& my $abs = time() + 15;
346 \& until ($ok = desired_condition($var)) {
347 \& last if !cond_timedwait($var, $abs);
348 \& }
349 \& # we got it if $ok, otherwise we timed out!
350 .Ve
351 .IP "cond_signal VARIABLE" 4
352 .IX Item "cond_signal VARIABLE"
353 The \f(CW\*(C`cond_signal\*(C'\fR function takes a \fBlocked\fR variable as a parameter and
354 unblocks one thread that\*(Aqs \f(CW\*(C`cond_wait\*(C'\fRing
355 on that variable. If more than one
356 thread is blocked in a \f(CW\*(C`cond_wait\*(C'\fR on that variable, only one (and which one
357 is indeterminate) will be unblocked.
358 .Sp
359 If there are no threads blocked in a \f(CW\*(C`cond_wait\*(C'\fR on the variable, the signal
360 is discarded. By always locking before
361 signaling, you can (with care), avoid
362 signaling before another thread has entered \fBcond_wait()\fR.
363 .Sp
364 \&\f(CW\*(C`cond_signal\*(C'\fR will normally generate a warning if you attempt to use it on an
365 unlocked variable. On the rare occasions
366 where doing this may be sensible, you
367 can suppress the warning with:
368 .Sp
369 .Vb 1
370 \& { no warnings \*(Aqthreads\*(Aq; cond_signal($foo); }
371 .Ve
372 .IP "cond_broadcast VARIABLE" 4
373 .IX Item "cond_broadcast VARIABLE"
374 The \f(CW\*(C`cond_broadcast\*(C'\fR function works similarly to \f(CW\*(C`cond_signal\*(C'\fR.
375 \&\f(CW\*(C`cond_broadcast\*(C'\fR, though, will unblock \fBall\fR the threads that are blocked in
376 a \f(CW\*(C`cond_wait\*(C'\fR on the locked variable, rather than only one.
377 .SH OBJECTS
378 .IX Header "OBJECTS"
379 threads::shared exports a version of \fBbless()\fR that
380 works on shared objects such that \fIblessings\fR propagate across threads.
381 .PP
382 .Vb 3
383 \& # Create a shared \*(AqFoo\*(Aq object
384 \& my $foo :shared = shared_clone({});
385 \& bless($foo, \*(AqFoo\*(Aq);
386 \&
387 \& # Create a shared \*(AqBar\*(Aq object
388 \& my $bar :shared = shared_clone({});
389 \& bless($bar, \*(AqBar\*(Aq);
390 \&
391 \& # Put \*(Aqbar\*(Aq inside \*(Aqfoo\*(Aq
392 \& $foo\->{\*(Aqbar\*(Aq} = $bar;
393 \&
394 \& # Rebless the objects via a thread
395 \& threads\->create(sub {
396 \& # Rebless the outer object
397 \& bless($foo, \*(AqYin\*(Aq);
398 \&
399 \& # Cannot directly rebless the inner object
400 \& #bless($foo\->{\*(Aqbar\*(Aq}, \*(AqYang\*(Aq);
401 \&
402 \& # Retrieve and rebless the inner object
403 \& my $obj = $foo\->{\*(Aqbar\*(Aq};
404 \& bless($obj, \*(AqYang\*(Aq);
405 \& $foo\->{\*(Aqbar\*(Aq} = $obj;
406 \&
407 \& })\->join();
408 \&
409 \& print(ref($foo), "\en"); # Prints \*(AqYin\*(Aq
410 \& print(ref($foo\->{\*(Aqbar\*(Aq}), "\en"); # Prints \*(AqYang\*(Aq
411 \& print(ref($bar), "\en"); # Also prints \*(AqYang\*(Aq
412 .Ve
413 .SH NOTES
414 .IX Header "NOTES"
415 threads::shared is designed to disable itself silently if threads are not
416 available. This allows you to write modules and packages that can be used
417 in both threaded and non\-threaded applications.
418 .PP
419 If you want access to threads, you must \f(CW\*(C`use threads\*(C'\fR before you
420 \&\f(CW\*(C`use threads::shared\*(C'\fR. threads will emit a warning if you use it after
421 threads::shared.
422 .SH WARNINGS
423 .IX Header "WARNINGS"
424 .IP "\fBcond_broadcast()\fR called on unlocked variable" 4
425 .IX Item "cond_broadcast() called on unlocked variable"
426 .PD 0
427 .IP "\fBcond_signal()\fR called on unlocked variable" 4
428 .IX Item "cond_signal() called on unlocked variable"
429 .PD
430 See "cond_signal VARIABLE", above.
431 .SH "BUGS AND LIMITATIONS"
432 .IX Header "BUGS AND LIMITATIONS"
433 When \f(CW\*(C`share\*(C'\fR is used on arrays, hashes, array refs or hash refs, any data
434 they contain will be lost.
435 .PP
436 .Vb 3
437 \& my @arr = qw(foo bar baz);
438 \& share(@arr);
439 \& # @arr is now empty (i.e., == ());
440 \&
441 \& # Create a \*(Aqfoo\*(Aq object
442 \& my $foo = { \*(Aqdata\*(Aq => 99 };
443 \& bless($foo, \*(Aqfoo\*(Aq);
444 \&
445 \& # Share the object
446 \& share($foo); # Contents are now wiped out
447 \& print("ERROR: \e$foo is empty\en")
448 \& if (! exists($foo\->{\*(Aqdata\*(Aq}));
449 .Ve
450 .PP
451 Therefore, populate such variables \fBafter\fR declaring them as shared. (Scalar
452 and scalar refs are not affected by this problem.)
453 .PP
454 Blessing a shared item after it has been nested in another shared item does
455 not propagate the blessing to the shared reference:
456 .PP
457 .Vb 5
458 \& my $foo = &share({});
459 \& my $bar = &share({});
460 \& $bar\->{foo} = $foo;
461 \& bless($foo, \*(Aqbaz\*(Aq); # $foo is now of class \*(Aqbaz\*(Aq,
462 \& # but $bar\->{foo} is unblessed.
463 .Ve
464 .PP
465 Therefore, you should bless objects before sharing them.
466 .PP
467 It is often not wise to share an object unless the class itself has been
468 written to support sharing. For example, a shared object\*(Aqs destructor may
469 get called multiple times, once for each thread\*(Aqs scope exit, or may not
470 get called at all if it is embedded inside another shared object. Another
471 issue is that the contents of hash\-based objects will be lost due to the
472 above mentioned limitation. See \fIexamples/class.pl\fR (in the CPAN
473 distribution of this module) for how to create a class that supports object
474 sharing.
475 .PP
476 Destructors may not be called on objects if those objects still exist at
477 global destruction time. If the destructors must be called, make sure
478 there are no circular references and that nothing is referencing the
479 objects before the program ends.
480 .PP
481 Does not support \f(CW\*(C`splice\*(C'\fR on arrays. Does not support explicitly changing
482 array lengths via $#array \-\- use \f(CW\*(C`push\*(C'\fR and \f(CW\*(C`pop\*(C'\fR instead.
483 .PP
484 Taking references to the elements of shared arrays and hashes does not
485 autovivify the elements, and neither does slicing a shared array/hash over
486 non\-existent indices/keys autovivify the elements.
487 .PP
488 \&\f(CWshare()\fR allows you to \f(CWshare($hashref\->{key})\fR and
489 \&\f(CWshare($arrayref\->[idx])\fR without giving any error message. But the
490 \&\f(CW\*(C`$hashref\->{key}\*(C'\fR or \f(CW\*(C`$arrayref\->[idx]\*(C'\fR is \fBnot\fR shared, causing
491 the error "lock can only be used on shared values" to occur when you attempt
492 to \f(CWlock($hashref\->{key})\fR or \f(CWlock($arrayref\->[idx])\fR in another
493 thread.
494 .PP
495 Using \f(CWrefaddr()\fR is unreliable for testing
496 whether or not two shared references are equivalent (e.g., when testing for
497 circular references). Use \fBis_shared()\fR, instead:
498 .PP
499 .Vb 3
500 \& use threads;
501 \& use threads::shared;
502 \& use Scalar::Util qw(refaddr);
503 \&
504 \& # If ref is shared, use threads::shared\*(Aqs internal ID.
505 \& # Otherwise, use refaddr().
506 \& my $addr1 = is_shared($ref1) || refaddr($ref1);
507 \& my $addr2 = is_shared($ref2) || refaddr($ref2);
508 \&
509 \& if ($addr1 == $addr2) {
510 \& # The refs are equivalent
511 \& }
512 .Ve
513 .PP
514 \&\fBeach()\fR does not work properly on shared references
515 embedded in shared structures. For example:
516 .PP
517 .Vb 2
518 \& my %foo :shared;
519 \& $foo{\*(Aqbar\*(Aq} = shared_clone({\*(Aqa\*(Aq=>\*(Aqx\*(Aq, \*(Aqb\*(Aq=>\*(Aqy\*(Aq, \*(Aqc\*(Aq=>\*(Aqz\*(Aq});
520 \&
521 \& while (my ($key, $val) = each(%{$foo{\*(Aqbar\*(Aq}})) {
522 \& ...
523 \& }
524 .Ve
525 .PP
526 Either of the following will work instead:
527 .PP
528 .Vb 4
529 \& my $ref = $foo{\*(Aqbar\*(Aq};
530 \& while (my ($key, $val) = each(%{$ref})) {
531 \& ...
532 \& }
533 \&
534 \& foreach my $key (keys(%{$foo{\*(Aqbar\*(Aq}})) {
535 \& my $val = $foo{\*(Aqbar\*(Aq}{$key};
536 \& ...
537 \& }
538 .Ve
539 .PP
540 This module supports dual\-valued variables created using \f(CWdualvar()\fR from
541 Scalar::Util. However, while \f(CW$!\fR acts
542 like a dualvar, it is implemented as a tied SV. To propagate its value, use
543 the follow construct, if needed:
544 .PP
545 .Vb 1
546 \& my $errno :shared = dualvar($!,$!);
547 .Ve
548 .PP
549 View existing bug reports at, and submit any new bugs, problems, patches, etc.
550 to: <http://rt.cpan.org/Public/Dist/Display.html?Name=threads\-shared>
551 .SH "SEE ALSO"
552 .IX Header "SEE ALSO"
553 threads::shared on MetaCPAN:
554 <https://metacpan.org/release/threads\-shared>
555 .PP
556 Code repository for CPAN distribution:
557 <https://github.com/Dual\-Life/threads\-shared>
558 .PP
559 threads, perlthrtut
560 .PP
561 <http://www.perl.com/pub/a/2002/06/11/threads.html> and
562 <http://www.perl.com/pub/a/2002/09/04/threads.html>
563 .PP
564 Perl threads mailing list:
565 <http://lists.perl.org/list/ithreads.html>
566 .PP
567 Sample code in the \fIexamples\fR directory of this distribution on CPAN.
568 .SH AUTHOR
569 .IX Header "AUTHOR"
570 Artur Bergman <sky AT crucially DOT net>
571 .PP
572 Documentation borrowed from the old Thread.pm.
573 .PP
574 CPAN version produced by Jerry D. Hedden <jdhedden AT cpan DOT org>.
575 .SH LICENSE
576 .IX Header "LICENSE"
577 threads::shared is released under the same license as Perl.