1Specific(3) User Contributed Perl Documentation Specific(3)
2
3
4
6 Coro::Specific - manage coroutine-specific variables.
7
9 use Coro::Specific;
10
11 my $ref = new Coro::Specific;
12
13 $$ref = 5;
14 print $$ref;
15
17 This module can be used to create variables (or better: references to
18 them) that are specific to the currently executing coroutine. This
19 module does not automatically load the Coro module (so the overhead
20 will be small when no coroutines are used).
21
22 A much faster method is to store extra keys into %$Coro::current - all
23 you have to do is to make sure that the key is unique (e.g. by
24 prefixing it with your module name). You can even store data there
25 before loading the Coro module - when Coro is loaded, the keys stored
26 in %$Coro::current are automatically attached to the coro thread
27 executing the main program.
28
29 You don't have to load "Coro::Specific" manually, it will be loaded
30 automatically when you "use Coro" and call the "new" constructor.
31
32 new Create a new coroutine-specific scalar and return a reference to
33 it. The scalar is guaranteed to be "undef". Once such a scalar has
34 been allocated you cannot deallocate it (yet), so allocate only
35 when you must.
36
38 The actual coroutine specific values do not automatically get destroyed
39 when the Coro::Specific object gets destroyed.
40
42 Marc A. Lehmann <schmorp@schmorp.de>
43 http://software.schmorp.de/pkg/Coro.html
44
45
46
47perl v5.34.0 2021-07-22 Specific(3)