Thread::Tie::Thread(3pm) | User Contributed Perl Documentation | Thread::Tie::Thread(3pm) |
Thread::Tie::Thread - create threads for tied variables
use Thread::Tie; # use as early as possible for maximum memory savings my $tiethread = Thread::Tie::Thread->new; tie stuff, 'Thread::Tie', {thread => $thread}; my $tid = $tiethread->tid; # thread id of tied thread my $thread = $tiethread->thread; # actual "threads" thread $tiethread->shutdown; # shut down specific thread
*** 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. It is of no use with any version of Perl before 5.8.0 or without threads 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.
There is only one class method.
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.
The following object methods are available for the instantiated Thread::Tie::Thread object.
my $tid = $tiethread->tid;
The "tid" object method returns the thread id of the actual threads thread that is being used.
my $thread = $tiethread->thread;
The "thread" object method returns the actual threads thread object that is being used.
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.
Elizabeth Mattijsen, <liz@dijkmat.nl>.
Please report bugs to <perlbugs@dijkmat.nl>.
Copyright (c) 2002-2003 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Thread::Tie, threads, AutoLoader.
2019-11-16 | perl v5.30.0 |