Thread::Tie::Thread3pm
Create threads for tied variables
Usage
use Thread::Tie; # use as early as possible for maximum memory savingsmy $tiethread = Thread::Tie::Thread->new;tie stuff, 'Thread::Tie', {thread => $thread};my $tid = $tiethread->tid; # thread id of tied threadmy $thread = $tiethread->thread; # actual "threads" thread$tiethread->shutdown; # shut down specific thread
Overview
*** A note of CAUTION ***This module only functions on Perl versions 5.8.0 and later.And then only when threads are enabled with -Dusethreads. Itis of no use with any version of Perl before 5.8.0 or withoutthreads enabled.*************************
The Thread::Tie::Thread module is a helper class for the Thread::Tie module. It is used to create the thread in which the actual code, to which variables are tied with the Thread::Tie class, is located.
Please see the documentation of the Thread::Tie module for more information.
Class methods
There is only one class method.
new
my $tiethread = Thread::Tie::Thread->new;
The "new" class method returns an instantiated object that can be specified with the "thread" field when tie()ing a variable.
Object methods
The following object methods are available for the instantiated Thread::Tie::Thread object.
tid
my $tid = $tiethread->tid;
The "tid" object method returns the thread id of the actual threads thread that is being used.
thread
my $thread = $tiethread->thread;
The "thread" object method returns the actual threads thread object that is being used.
Optimizations
This module uses AutoLoader to reduce memory and CPU usage. This causes subroutines only to be compiled in a thread when they are actually needed at the expense of more CPU when they need to be compiled. Simple benchmarks however revealed that the overhead of the compiling single routines is not much more (and sometimes a lot less) than the overhead of cloning a Perl interpreter with a lot of subroutines pre-loaded.
Releases
5 releases since Debian 9 (Stretch); the text changed 3 times.