Skip to content

Commit a5f284a

Browse files
committed
perlembed, perlthrtut, Clarify threads vs ithreads
This fixes #15573
1 parent d85c3a2 commit a5f284a

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

pod/perlembed.pod

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -927,16 +927,26 @@ perl_construct resets it to C<0>.
927927

928928
Now suppose we have more than one interpreter instance running at the
929929
same time. This is feasible, but only if you used the Configure option
930-
C<-Dusemultiplicity> or the options C<-Dusethreads -Duseithreads> when
931-
building perl. By default, enabling one of these Configure options
932-
sets the per-interpreter global variable C<PL_perl_destruct_level> to
933-
C<1>, so that thorough cleaning is automatic and interpreter variables
934-
are initialized correctly. Even if you don't intend to run two or
935-
more interpreters at the same time, but to run them sequentially, like
936-
in the above example, it is recommended to build perl with the
937-
C<-Dusemultiplicity> option otherwise some interpreter variables may
938-
not be initialized correctly between consecutive runs and your
939-
application may crash.
930+
C<-Dusemultiplicity> or either of the options C<-Dusethreads
931+
-Duseithreads> when building perl. By default, enabling one of these
932+
Configure options sets the per-interpreter global variable
933+
C<PL_perl_destruct_level> to C<1>, so that thorough cleaning is
934+
automatic and interpreter variables are initialized correctly. Even if
935+
you don't intend to run two or more interpreters at the same time, but
936+
to run them sequentially, like in the above example, it is recommended
937+
to build perl with the C<-Dusemultiplicity> option otherwise some
938+
interpreter variables may not be initialized correctly between
939+
consecutive runs and your application may crash.
940+
941+
(It used to be that there were two forms of threads, with C<ithreads>
942+
appearing later. But C<ithreads> proved to be superior, and support for
943+
the older model was removed in Perl v5.10. But the documentation and
944+
code have never been purged of the earlier terminology; and perhaps some
945+
newer model will come along to supplant C<ithreads>, so it seems best to
946+
retain both. If you don't care about the threading model used, use
947+
plain C<threads> to protect your code from having to change with future
948+
developments. If your code is dependent on the C<ithreads> model, use
949+
C<ithreads> to make sure you will always get that.)
940950

941951
See also L<perlclib/Dealing with embedded perls and threads>.
942952

pod/perlthrtut.pod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ have C<use5005threads=define> you have 5.005 threads.
2525
If you have neither, you don't have any thread support built in.
2626
If you have both, you are in trouble.
2727

28+
In more modern times, the terms C<ithreads> and C<threads> are
29+
synonymous, and are used interchangeably. The best practice is to use
30+
C<ithreads> if your code is dependent on something specific about that
31+
implementation, and to use C<threads> if it isn't. That way, in the
32+
very unlikely event that some new threading model comes along, your code
33+
is more protected from needing to change.
34+
2835
The L<threads> and L<threads::shared> modules are included in the core Perl
2936
distribution. Additionally, they are maintained as separate modules on
3037
CPAN, so you can check there for any updates.

0 commit comments

Comments
 (0)