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