Don't display debug data.
[p5sagit/p5-mst-13.2.git] / ext / threads / threads.pm
CommitLineData
47ba8780 1package threads;
2
3use 5.7.2;
4use strict;
5use warnings;
6
7use overload
8 '==' => \&equals,
9 'fallback' => 1;
10
47ba8780 11#use threads::Shared;
12
13require Exporter;
14require DynaLoader;
15
47ba8780 16our @ISA = qw(Exporter DynaLoader);
17
18our %EXPORT_TAGS = ( all => [qw()]);
19
20our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
21
22our @EXPORT = qw(
23
24);
25our $VERSION = '0.05';
26
27sub new {
28 my $class = shift;
47ba8780 29 return $class->create(@_);
30}
31
32
33sub equals {
34 return 1 if($_[0]->tid() == $_[1]->tid());
35 return 0;
36}
37
38$Config::threads = 1;
39
40bootstrap threads $VERSION;
41
47ba8780 42# Preloaded methods go here.
43
441;
45__END__
46
47=head1 NAME
48
49threads - Perl extension allowing use of interpreter based threads from perl
50
51=head1 SYNOPSIS
52
47ba8780 53use threads;
54
55sub start_thread {
56 print "Thread started\n";
57}
58
47ba8780 59my $thread = threads->new("start_thread","argument");
60
61$thread->new(sub { print "I am a thread"},"argument");
62
63$thread->join();
64
65$thread->detach();
66
67$thread = threads->self();
68
69thread->tid();
70
47ba8780 71=head1 DESCRIPTION
72
ad91d581 73Perl 5.6 has something called interpreter threads, interpreter threads
74are built on MULTIPLICITY and allows for several different perl
75interpreters to run in different threads. This has been used in win32
76perl to fake forks, it has also been available to people embedding
77perl.
47ba8780 78
79=over
80
81=item new, function, LIST
82
ad91d581 83This will create a new thread with the entry point function and give
84it LIST as parameters. It will return the corresponding threads
85object.
47ba8780 86
87=item $threads->join
88
89This will wait for the corresponding thread to join. When it finishes join will return the return values of the root function.
90If a thread has been detached, join will return without wait.
91
92=item $threads->detach
93
94Will throw away the return value from the thread and make non joinable
95
96=item threads->self
97
98This will return the object for the current thread.
99
100=item $threads->tid
101
102This will return the id of the thread.
103threads->self->tid() is a quick way to get current thread id
104
105=back
106
107
108=head1 TODO
109
110=over
111
112=item Fix so the return value is returned when you join
113
114=item Add join_all
115
116=item Fix memory leaks!
117
118=back
119
120=head1 AUTHOR and COPYRIGHT
121
ad91d581 122Artur Bergman E<lt>artur at contiller.seE<gt>
47ba8780 123
124threads is released under the same license as Perl
125
126Thanks to
127
ad91d581 128Richard Soderberg E<lt>rs at crystalflame.netE<gt>
129Helping me out tons, trying to find reasons for races and other weird bugs!
47ba8780 130
ad91d581 131Simon Cozens E<lt>simon at brecon.co.ukE<gt>
132Being there to answer zillions of annoying questions
47ba8780 133
ad91d581 134Rocco Caputo E<lt>troc at netrus.netE<gt>
47ba8780 135
ad91d581 136Vipul Ved Prakash E<lt>mail at vipul.netE<gt>
47ba8780 137Helping with debugging.
138
139please join perl-ithreads@perl.org for more information
140
141=head1 BUGS
142
143=over
144
145=item creating a thread from within a thread is unsafe under win32
146
b5807cdb 147=item PERL_OLD_SIGNALS are not threadsafe, will not be.
148
47ba8780 149=back
150
151=head1 SEE ALSO
152
153L<perl>, L<perlcall>, L<perlembed>, L<perlguts>
154
155=cut