X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=ext%2Fthreads%2Fthreads.pm;h=86f8766c400107d28575908cc523a6466dc811f9;hb=8c9849ff798160d7f115286b222762e1c4e65f66;hp=6ad724e0a2a5894b2155573c461c73dbf256c35b;hpb=739c8b3a364622b7992851a224b3e6424e7e3b03;p=p5sagit%2Fp5-mst-13.2.git diff --git a/ext/threads/threads.pm b/ext/threads/threads.pm index 6ad724e..86f8766 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