Thread...:Thread(3pm)
π NAME π
Thread::Tie::Thread β bestie, this is the one that creates threads for tied variables β¨
πΈ SYNOPSIS πΈ
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
π DESCRIPTION π
* 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. *
Okay so real talk π
Thread::Tie::Thread is a little helper class for the Thread::Tie module. Its whole job? Making the thread where your actual code lives β the code that the variables tied with the Thread::Tie class hang out in. π«Ά
If you want the full tea, go read the docs for the Thread::Tie module itself, bestie. π
π CLASS METHODS π
There is only one class method. One. Singular. Iconic behaviour, honestly. β¨
π new
my $tiethread = Thread::Tie::Thread->new;
The "new" class method hands you back an instantiated object π β and you can pass that object along in the "thread" field when you tie() a variable. That's the whole vibe. π
π¦ OBJECT METHODS π¦
Once you've got your instantiated Thread::Tie::Thread object, these are the object methods you can call on it, bestie. π
β tid
my $tid = $tiethread->tid;
The "tid" object method gives you the thread id of the actual threads thread that's being used π₯
π thread
my $thread = $tiethread->thread;
The "thread" object method gives you the actual threads thread object that's being used. Yep, the real one. π
π§ OPTIMIZATIONS π§
This module uses AutoLoader to reduce memory and CPU usage π§ β¨. What that means: subroutines only get compiled in a thread when they're actually needed β the tradeoff being more CPU when they do eventually need to be compiled.
But no cap, simple benchmarks showed the overhead of compiling single routines is not much more (and sometimes a lot less) than the overhead of cloning a Perl interpreter with a bunch of subroutines pre-loaded. So likeβ¦ slay, honestly. π
π AUTHOR π
Elizabeth Mattijsen, <liz@dijkmat.nl>.
maintained by LNATION <email@lnation.org>
Please report bugs to <email@lnation.org>>.
π COPYRIGHT π
Copyright (c) 2002-2003 Elizabeth Mattijsen <liz@dijkmat.nl>. 2019 - 2025 LNATION <email@lnation.org> All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SEE ALSO π
Thread::Tie, threads, AutoLoader.
okay that's the whole page, periodt π this was perl v5.40.1, dated 2025-04-25, from Thread...:Thread(3pm) β go forth and tie responsibly, bestie π«Άβ¨
π¦ where this page comes from
- debian trixie: libthread-tie-perl 0.16-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libthread-tie-perl 0.16-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libthread-tie-perl 0.16-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms