Skip to content

Commit 145005a

Browse files
committed
Initial doc for Thread.is-initial-thread
1 parent f4f6670 commit 145005a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/Type/Thread.pod6

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ L<name|#method_name>.
135135
my $t = Thread.new(code => { for 1..5 -> $v { say $v }}, name => 'calc thread');
136136
say $t.Str; # OUTPUT: «Thread<3>(calc thread)␤»
137137
138+
=head2 method is-initial-thread
139+
140+
method is-initial-thread(--> Bool)
141+
142+
Returns a Bool indicating whether the current thread (if called as a class
143+
method) or the Thread object on which it is called, is the initial thread
144+
of the program seen from a HLL-language perspective.
145+
146+
say Thread.is-initial-thread; # True if this is the initial thread
147+
say $*THREAD.is-initial-thread; # True if $*THREAD is the initial thread
148+
149+
Please note there is no guarantee that this is actually the main thread from
150+
the OS's point of view. Also note that if you need this other than from a
151+
pure introspection / debugging point of view, that there are probably better
152+
ways to achieve what you're trying to achieve.
153+
138154
=head1 Routines
139155
140156
=head2 sub full-barrier

0 commit comments

Comments
 (0)