diff options
author | Elizabeth Mattijsen <liz@dijkmat.nl> | 2002-07-12 02:27:53 +0200 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-07-12 12:43:15 +0000 |
commit | 8c9849ff798160d7f115286b222762e1c4e65f66 (patch) | |
tree | b4cd62c334b253cb95d90956bb1f9a645f628310 /ext | |
parent | 739c8b3a364622b7992851a224b3e6424e7e3b03 (diff) | |
download | perl-8c9849ff798160d7f115286b222762e1c4e65f66.tar.gz |
Re: Thread object by tid?
Message-Id: <4.2.0.58.20020712002638.0218ce10@mickey.dijkmat.nl>
p4raw-id: //depot/perl@17499
Diffstat (limited to 'ext')
-rwxr-xr-x | ext/threads/threads.pm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/threads/threads.pm b/ext/threads/threads.pm index 6ad724e0a2..86f8766c40 100755 --- a/ext/threads/threads.pm +++ b/ext/threads/threads.pm @@ -65,6 +65,14 @@ sub async (&;@) { return threads->new($cref,@_); } +sub object { + return undef unless @_ > 1; + foreach (threads->list) { + return $_ if $_->tid == $_[1]; + } + return undef; +} + $threads::threads = 1; bootstrap threads $VERSION; @@ -97,6 +105,7 @@ threads - Perl extension allowing use of interpreter based threads from perl $thread->detach(); $thread = threads->self(); + $thread = threads->object( $tid ); $thread->tid(); threads->tid(); @@ -166,6 +175,12 @@ new thread that's created. NB the class method C<< threads->tid() >> is a quick way to get the current thread id if you don't have your thread object handy. +=item threads->object( tid ) + +This will return the thread object for the thread associated with the +specified tid. Returns undef if there is no thread associated with the tid +or no tid is specified or the specified tid is undef. + =item threads->yield(); This is a suggestion to the OS to let this thread yield CPU time to other |