=encoding euc-jp =head1 NAME =begin original threads - Perl interpreter-based threads =end original threads - Perl �Υ��󥿥ץ꥿�١����Υ���å� =head1 VERSION =begin original This document describes threads version 1.67 =end original ����ʸ��� threads �С������ 1.67 �򵭽Ҥ��Ƥ��ޤ��� =head1 SYNOPSIS use threads ('yield', 'stack_size' => 64*4096, 'exit' => 'threads_only', 'stringify'); sub start_thread { my @args = @_; print('Thread started: ', join(' ', @args), "\n"); } my $thr = threads->create('start_thread', 'argument'); $thr->join(); threads->create(sub { print("I am a thread\n"); })->join(); my $thr2 = async { foreach (@files) { ... } }; $thr2->join(); if (my $err = $thr2->error()) { warn("Thread error: $err\n"); } # Invoke thread in list context (implicit) so it can return a list my ($thr) = threads->create(sub { return (qw/a b c/); }); # or specify list context explicitly my $thr = threads->create({'context' => 'list'}, sub { return (qw/a b c/); }); my @results = $thr->join(); $thr->detach(); # Get a thread's object $thr = threads->self(); $thr = threads->object($tid); # Get a thread's ID $tid = threads->tid(); $tid = $thr->tid(); $tid = "$thr"; # Give other threads a chance to run threads->yield(); yield(); # Lists of non-detached threads my @threads = threads->list(); my $thread_count = threads->list(); my @running = threads->list(threads::running); my @joinable = threads->list(threads::joinable); # Test thread objects if ($thr1 == $thr2) { ... } # Manage thread stack size $stack_size = threads->get_stack_size(); $old_size = threads->set_stack_size(32*4096); # Create a thread with a specific context and stack size my $thr = threads->create({ 'context' => 'list', 'stack_size' => 32*4096, 'exit' => 'thread_only' }, \&foo); # Get thread's context my $wantarray = $thr->wantarray(); # Check thread's state if ($thr->is_running()) { sleep(1); } if ($thr->is_joinable()) { $thr->join(); } # Send a signal to a thread $thr->kill('SIGUSR1'); # Exit a thread threads->exit(); =head1 DESCRIPTION =begin original Perl 5.6 introduced something called interpreter threads. Interpreter threads are different from I<5005threads> (the thread model of Perl 5.005) by creating a new Perl interpreter per thread, and not sharing any data or state between threads by default. =end original Perl 5.6 �ϥ��󥿥ץ꥿����åɤȸƤФ���Τ�Ƴ�����ޤ����� ���󥿥ץ꥿����åɤϡ�����å���˿����� Perl ���󥿥ץ꥿�� �������뤳�Ȥˤ�äơ��ޤ����ǥե���ȤǤϤ����ʤ�ǡ�������֤� ����åɴ֤Ƕ�ͭ���ʤ����Ȥˤ�äơ�I<5005����å�> (Perl 5.005 �ˤ����륹��åɥ�ǥ�)�Ȥ϶��̤���ޤ��� =begin original Prior to Perl 5.8, this has only been available to people embedding Perl, and for emulating fork() on Windows. =end original Perl 5.8 ������Ǥϡ������ Perl ���Ȥ߹��ह��͡��ˤȤäƤΤߡ� ������ Windows �� fork() �򥨥ߥ�졼�Ȥ��뤿��ˤΤ����Ѳ�ǽ�Ǥ����� =begin original The I API is loosely based on the old Thread.pm API. It is very important to note that variables are not shared between threads, all variables are by default thread local. To use shared variables one must also use L: =end original I API �ϡ��Ť� Thread.pm API �ˤ����ޤ��˴�Ť��Ƥ��ޤ��� �ѿ��ϥ���åɴ֤Ƕ�ͭ���줺�����Ƥ��ѿ��ϥǥե���Ȥ� ����åɥ�������ʤ�ΤǤ��뤳�Ȥ����դ��Ƥ������Ȥ����˽��פǤ��� ��ͭ�ѿ������Ѥ���ˤϡ�L ��Ȥ�ʤ���Фʤ�ޤ��� use threads; use threads::shared; =begin original It is also important to note that you must enable threads by doing C as early as possible in the script itself, and that it is not possible to enable threading inside an C, C, C, or C. In particular, if you are intending to share variables with L, you must C before you C. (C will emit a warning if you do it the other way around.) =end original �ޤ���������ץ���ǤϤǤ�������ᤤ������ C ���� ����åɤ����Ѳ�ǽ�ˤ��Ƥ����٤������� C, C, C, C �������Ǥ� ����å����Ǥ��ʤ����Ȥ����դ��Ƥ��������� �ä� L ��Ȥä��ѿ���ͭ���褦�Ȥ���ʤ�С� C ������ C ���ʤ���Фʤ�ޤ��� (�դˤ��Ƥ��ޤ��� C �Ϸٹ��ȯ���ޤ���) =over =item $thr = threads->create(FUNCTION, ARGS) =begin original This will create a new thread that will begin execution with the specified entry point function, and give it the I list as parameters. It will return the corresponding threads object, or C if thread creation failed. =end original ����ϻ��ꤵ�줿����ȥ�ݥ���ȴؿ��μ¹Ԥ򳫻Ϥ��������Ȥ��� I �ꥹ�Ȥ�Ϳ�����뿷��������åɤ���ޤ��� �б����륹��åɥ��֥������Ȥ�������åɺ����˼��Ԥ������� C ���֤��ޤ��� =begin original I may either be the name of a function, an anonymous subroutine, or a code ref. =end original I �ϴؿ�̾��̵̾���֥롼���󡢥����ɥ�ե���󥹤Τ����줫�Ǥ��� my $thr = threads->create('func_name', ...); # or my $thr = threads->create(sub { ... }, ...); # or my $thr = threads->create(\&func, ...); =begin original The C<-Enew()> method is an alias for C<-Ecreate()>. =end original C<-Enew()> �᥽�åɤ� C<-Ecreate()> �Υ����ꥢ���Ǥ��� =item $thr->join() =begin original This will wait for the corresponding thread to complete its execution. When the thread finishes, C<-Ejoin()> will return the return value(s) of the entry point function. =end original �б����륹��åɤ��¹Ԥ�λ����Τ��Ԥ��ޤ��� ���Υ���åɤ���λ��������C<-Ejoin()> �� ����ȥ�ݥ���ȴؿ�������ͤ��֤��ޤ��� =begin original The context (void, scalar or list) for the return value(s) for C<-Ejoin()> is determined at the time of thread creation. =end original C<-Ejoin()> �Υ���ƥ����� (̵���������顢�ꥹ�ȤΤ����줫) �ϡ� ����å��������˷��ꤵ��ޤ��� # Create thread in list context (implicit) my ($thr1) = threads->create(sub { my @results = qw(a b c); return (@results); }); # or (explicit) my $thr1 = threads->create({'context' => 'list'}, sub { my @results = qw(a b c); return (@results); }); # Retrieve list results from thread my @res1 = $thr1->join(); # Create thread in scalar context (implicit) my $thr2 = threads->create(sub { my $result = 42; return ($result); }); # Retrieve scalar result from thread my $res2 = $thr2->join(); # Create a thread in void context (explicit) my $thr3 = threads->create({'void' => 1}, sub { print("Hello, world\n"); }); # Join the thread in void context (i.e., no return value) $thr3->join(); =begin original See L for more details. =end original ����ʤ�ܺ٤ˤĤ��Ƥ� L �򻲾Ȥ��Ƥ��������� =begin original If the program exits without all threads having either been joined or detached, then a warning will be issued. =end original ���ƤΥ���åɤ� join ����뤫 detach ��������˥ץ�����ब��λ������硢 �ٹ�ȯ�����ޤ��� =begin original Calling C<-Ejoin()> or C<-Edetach()> on an already joined thread will cause an error to be thrown. =end original ���� join ���Ƥ��륹��åɤ��Ф��� C<-Ejoin()> �� C<-Edetach()> �� �Ԥ��ȡ����顼��ȯ�����ޤ��� =item $thr->detach() =begin original Makes the thread unjoinable, and causes any eventual return value to be discarded. When the program exits, any detached threads that are still running are silently terminated. =end original ����åɤ� join �Բ�ǽ�ˤ����ǽ�Ū���֤��ͤ�ΤƤ�褦�ˤ��ޤ��� �ץ�����ब��λ����Ȥ����ޤ��¹���� detach ���줿����åɤϰ��ۤ� ��λ���ޤ��� =begin original If the program exits without all threads having either been joined or detached, then a warning will be issued. =end original ���ƤΥ���åɤ� join ����뤫 detach ��������˥ץ�����ब��λ������硢 �ٹ�ȯ�����ޤ��� =begin original Calling C<-Ejoin()> or C<-Edetach()> on an already detached thread will cause an error to be thrown. =end original ���� detach ���줿����åɤ� C<-Ejoin()> �� C<-Edetach()> �� �ƤӽФ��ȡ����顼��ȯ�����ޤ��� =item threads->detach() =begin original Class method that allows a thread to detach itself. =end original ����åɤ���ʬ���Ȥ� detach ���뤿��Υ��饹�᥽�åɤǤ��� =item threads->self() =begin original Class method that allows a thread to obtain its own I object. =end original ����åɤ����Ȥ� I ���֥������Ȥ�������뤿��Υ��饹�᥽�åɤǤ��� =item $thr->tid() =begin original Returns the ID of the thread. Thread IDs are unique integers with the main thread in a program being 0, and incrementing by 1 for every thread created. =end original ����åɤ� ID ���֤��ޤ��� ����å� ID �ϥ�ˡ����������Ǥ��ꡢ�ץ������λϤޤ�Ȥʤ� �ᥤ�󥹥�åɤ��ͤ� 0 �ǡ� ����������åɤ���������뤿�Ӥ��ͤ� 1 ���䤷�Ƥ����ޤ��� =item threads->tid() =begin original Class method that allows a thread to obtain its own ID. =end original ����åɤ����Ȥ� ID �����뤿��Υ��饹�᥽�åɤǤ��� =item "$thr" =begin original If you add the C import option to your C declaration, then using a threads object in a string or a string context (e.g., as a hash key) will cause its ID to be used as the value: =end original C ����� C ����ݡ��ȥ��ץ������ɲä���ȡ� ʸ�����ʸ���󥳥�ƥ����� (�㤨�Хϥå���Υ����Ȥ���) �� ����åɥ��֥������Ȥ�Ȥ����Ȥ���ȡ����� ID ���ͤȤ��ƻȤ��ޤ�: use threads qw(stringify); my $thr = threads->create(...); print("Thread $thr started...\n"); # Prints out: Thread 1 started... =item threads->object($tid) =begin original This will return the I object for the I thread associated with the specified thread ID. Returns C if there is no thread associated with the TID, if the thread is joined or detached, if no TID is specified or if the specified TID is undef. =end original ���ꤵ�줿����åɤ˴�Ϣ���륢���ƥ��֤� I ���֥������Ȥ��֤��ޤ��� �⤷ TID �ǻ��ꤵ�줿����åɤ��ʤ���硢join �� detach ����Ƥ����硢 TID �����ꤵ��Ƥ��ʤ���硢���ꤵ�줿 TID �� undef �� ��硢�᥽�åɤ� C ���֤��ޤ��� =item threads->yield() =begin original This is a suggestion to the OS to let this thread yield CPU time to other threads. What actually happens is highly dependent upon the underlying thread implementation. =end original ���Υ���åɤ�¾�Υ���åɤ� CPU ���֤���äƤ⤤���Ȥ������Ȥ� OS �� �������ޤ��� �ºݤ˵����뤳�Ȥϡ���ˤʤäƤ��륹��åɼ������礭����¸���Ƥ��ޤ��� =begin original You may do C, and then just use C in your code. =end original ��������Ǥϡ�C ���Ƥ��顢ñ�� C �� �Ȥ��ޤ��� =item threads->list() =item threads->list(threads::all) =item threads->list(threads::running) =item threads->list(threads::joinable) =begin original With no arguments (or using C) and in a list context, returns a list of all non-joined, non-detached I objects. In a scalar context, returns a count of the same. =end original �����ʤ��� (�ޤ��� C ��Ȥä�) �ꥹ�ȥ���ƥ����Ȥξ�硢 join ����Ƥ��餺��detach ����Ƥ��ʤ����Ƥ� I ���֥������Ȥ� �ꥹ�Ȥ��֤��ޤ��� �����饳��ƥ����ȤǤϡ���ҤΤ�Το����֤��ޤ��� =begin original With a I argument (using C), returns a list of all non-joined, non-detached I objects that are still running. =end original ������ I<��> �� (�ޤ��� C ��Ȥä�) ��硢 join ����Ƥ��餺��detach ����Ƥ��ʤ����ޤ��¹���� I ���֥������ȤΥꥹ�Ȥ��֤��ޤ��� =begin original With a I argument (using C), returns a list of all non-joined, non-detached I objects that have finished running (i.e., for which C<-Ejoin()> will not I). =end original ������ I<��> �� (�ޤ��� C ��Ȥä�) ��硢 join ����Ƥ��餺��detach ����Ƥ��ʤ����¹Ԥ���λ���� (�Ĥޤ� C<-Ejoin()> �� I<�֥��å�> ����ʤ�) I ���֥������Ȥ� �ꥹ�Ȥ��֤��ޤ��� =item $thr1->equal($thr2) =begin original Tests if two threads objects are the same thread or not. This is overloaded to the more natural forms: =end original 2 �ĤΥ���åɥ��֥������Ȥ�Ʊ������åɤ��ɤ�����ƥ��Ȥ��ޤ��� ����Ϥ�꼫���ʷ��˥����С������ɤ���ޤ�: if ($thr1 == $thr2) { print("Threads are the same\n"); } # or if ($thr1 != $thr2) { print("Threads differ\n"); } =begin original (Thread comparison is based on thread IDs.) =end original (����åɤ���Ӥϥ���å� ID ���ˤ��ޤ���) =item async BLOCK; =begin original C creates a thread to execute the block immediately following it. This block is treated as an anonymous subroutine, and so must have a semicolon after the closing brace. Like Ccreate()>, C returns a I object. =end original C �Ϥ���ľ���³���֥��å���¹Ԥ��륹��åɤ��������ޤ��� ���Υ֥��å���̵̾���֥롼����Ȥ��ư�����Τǡ��Ĥ����̤θ�� ���ߥ������Ĥ��ʤ���Фʤ�ޤ��� Ccreate()> Ʊ�͡�C �� I ���֥������Ȥ��֤��ޤ��� =item $thr->error() =begin original Threads are executed in an C context. This method will return C if the thread terminates I. Otherwise, it returns the value of C<$@> associated with the thread's execution status in its C context. =end original ����åɤ� C<̵��> ����ƥ����ȤǼ¹Ԥ���ޤ��� ���Υ᥽�åɤϡ�����åɤ� I<���̤�> ��λ�������� C ���֤��ޤ��� ����ʤ���С�����åɤμ¹Ծ��֤˴�Ϣ�Ť���줿 C<$@> ���ͤ� C<̵��> ����ƥ����Ȥ��֤��ޤ��� =item $thr->_handle() =begin original This I method returns the memory location of the internal thread structure associated with a threads object. For Win32, this is a pointer to the C value returned by C (i.e., C); for other platforms, it is a pointer to the C structure used in the C call (i.e., C). =end original ���� I<�ץ饤�١���> �᥽�åɤϡ�����åɥ��֥������Ȥ˴�Ϣ�Ť���줿 ��������åɹ�¤�ΤΥ�����֤��֤��ޤ��� Win32 �Ǥϡ������ C �����֤���� C �ͤؤΥݥ��� (�Ĥޤ� C) �Ǥ�; ����¾�Υץ�åȥե�����Ǥϡ� C �ƤӽФ��ǻȤ��� C ��¤�ΤؤΥݥ��� (�Ĥޤ� C) �Ǥ��� =begin original This method is of no use for general Perl threads programming. Its intent is to provide other (XS-based) thread modules with the capability to access, and possibly manipulate, the underlying thread structure associated with a Perl thread. =end original ���Υ᥽�åɤϡ�����Ū�� Perl ����åɥץ�����ߥ󥰤ˤ�̵�ѤǤ��� ���Υ᥽�åɤ���Ū�ϡ�����¾�� (XS �١�����) ����åɥ⥸�塼�뤬�� Perl ����åɤȴ�Ϣ�Ť����Ƥ�����äȤʤ륹��åɹ�¤�ΤؤΥ������������ �����餯�������ǽ�ˤ��뤳�ȤǤ��� =item threads->_handle() =begin original Class method that allows a thread to obtain its own I. =end original ����åɤ����Ȥ� I �����뤿��Υ��饹�᥽�åɤǤ��� =back =head1 EXITING A THREAD (����åɤν�λ) =begin original The usual method for terminating a thread is to L from the entry point function with the appropriate return value(s). =end original ����åɤ�λ���뤿����̾�μ�ˡ�ϡ�����ȥ�ݥ���ȴؿ��� Ŭ�ڤ��֤��ͤȶ��� L ��Ȥ����ȤǤ��� =over =item threads->exit() =begin original If needed, a thread can be exited at any time by calling Cexit()>. This will cause the thread to return C in a scalar context, or the empty list in a list context. =end original �⤷ɬ�פʤ顢����åɤϤ��ĤǤ� Cexit()> �� �ƤӽФ����Ȥǽ�λ�����뤳�Ȥ�����ޤ��� ����ˤ�ꡢ����åɤϥ����饳��ƥ����ȤǤ� C ���֤��� �ꥹ�ȥ���ƥ����ȤǤ϶��ꥹ�Ȥ��֤��ޤ��� =begin original When called from the I
thread, this behaves the same as C. =end original I
����åɤ���ƤӽФ����ȡ�C ��Ʊ�ͤ˿����񤤤ޤ��� =item threads->exit(status) =begin original When called from a thread, this behaves like Cexit()> (i.e., the exit status code is ignored). =end original ����åɤ���ƤӽФ����ȡ�Cexit()> ��Ʊ�ͤ˿����񤤤ޤ� (�Ĥޤꡢstatus ��λ�����ɤ�̵�뤵��ޤ�)�� =begin original When called from the I
thread, this behaves the same as C. =end original I
����åɤ���ƤӽФ����ȡ�C ��Ʊ�ͤ˿����񤤤ޤ��� =item die() =begin original Calling C in a thread indicates an abnormal exit for the thread. Any C<$SIG{__DIE__}> handler in the thread will be called first, and then the thread will exit with a warning message that will contain any arguments passed in the C call. =end original ����åɤǤ� C �θƤӽФ��ϡ�����åɤΰ۾ェλ���̣���ޤ��� �ޤ�����åɤǤ� C<$SIG{__DIE__}> �ϥ�ɥ餬�ƤӽФ��졢 ���줫�饹��åɤ� C �ƤӽФ����Ϥ��줿�����ˤ��ٹ��å������� ���˽�λ���ޤ��� =item exit(status) =begin original Calling L inside a thread causes the whole application to terminate. Because of this, the use of C inside threaded code, or in modules that might be used in threaded applications, is strongly discouraged. =end original ����åɤ������� L ��ƤӽФ��ȡ� ���ץꥱ����������Τ���λ���ޤ��� ����Τ��Ȥˤ�ꡢ����åɥ����������䡢����åɲ����줿 ���ץꥱ�������ǻȤ��뤫���Τ�ʤ��⥸�塼��Ǥ� C �λ��Ѥ� ������侩�Ǥ��� =begin original If C really is needed, then consider using the following: =end original �⤷������ C ��ɬ�פʤ顢�ʲ���Ȥ����Ȥ�ͤ��Ƥ�������: threads->exit() if threads->can('exit'); # Thread friendly exit(status); =item use threads 'exit' => 'threads_only' =begin original This globally overrides the default behavior of calling C inside a thread, and effectively causes such calls to behave the same as Cexit()>. In other words, with this setting, calling C causes only the thread to terminate. =end original ����ϥ���å���Ǥ� C �ƤӽФ��Υǥե���Ȥο����񤤤򥰥����Х�� ��񤭤������¾夳�Τ褦�ʸƤӽФ��� Cexit()> ��Ʊ�� �����񤤤ˤ��ޤ��� ����������ȡ���������ˤ�äơ�C ��ƤӽФ����Ȥ��˥���åɤ����� ��λ�����ޤ��� =begin original Because of its global effect, this setting should not be used inside modules or the like. =end original ����ϥ������Х�ʸ��̤���ĤΤǡ���������ϥ⥸�塼��Τ褦�ʤ�Τ������Ǥ� �Ȥ��٤��ǤϤ���ޤ��� =begin original The I
thread is unaffected by this setting. =end original I
����åɤϤ�������αƶ�������ޤ��� =item threads->create({'exit' => 'thread_only'}, ...) =begin original This overrides the default behavior of C inside the newly created thread only. =end original ����Ͽ��������줿����åɤ���¦�Ǥ��� C �Υǥե���Ȥ� �����񤤤��񤭤��ޤ��� =item $thr->set_thread_exit_only(boolean) =begin original This can be used to change the I behavior for a thread after it has been created. With a I argument, C will cause only the thread to exit. With a I argument, C will terminate the application. =end original ����ϡ�����åɤ� I<����åɤ�����λ> �ο����񤤤򡢥���åɤ����줿 ����ѹ����뤿��˻Ȥ��ޤ��� I<��> ���ͤ��Ϥ��ȡ�C �ˤ�äƥ���åɤ�������λ���ޤ��� I<��> ���ͤ��Ϥ��ȡ�C �ˤ�äƥ��ץꥱ������󤬽�λ���ޤ��� =begin original The I
thread is unaffected by this call. =end original I
����åɤϤ��θƤӽФ��αƶ�������ޤ��� =item threads->set_thread_exit_only(boolean) =begin original Class method for use inside a thread to change its own behavior for C. =end original C �ο����񤤤��Ѥ��뤿��˥���åɤ���¦�ǻȤ������ ���饹�᥽�åɤǤ��� =begin original The I
thread is unaffected by this call. =end original I
����åɤϤ��θƤӽФ��αƶ�������ޤ��� =back =head1 THREAD STATE (����åɤξ���) =begin original The following boolean methods are useful in determining the I of a thread. =end original �ʲ��ο����ͥ᥽�åɤϥ���åɤ� I<����> ����ꤹ��Τ������Ǥ��� =over =item $thr->is_running() =begin original Returns true if a thread is still running (i.e., if its entry point function has not yet finished or exited). =end original ����åɤ��ޤ��¹Ԥ���Ƥ���(�Ĥޤꡢ���Υ���ȥ�ݥ���ȴؿ����ޤ���λ�ޤ��� ��λ���Ƥ��ʤ�)�ʤ鿿���֤��ޤ��� =item $thr->is_joinable() =begin original Returns true if the thread has finished running, is not detached and has not yet been joined. In other words, the thread is ready to be joined, and a call to C<$thr-Ejoin()> will not I. =end original ����åɤ��¹Ԥ�λ���Ƥ��ơ�detach �� join �⤵��Ƥ��ʤ��ʤ鿿���֤��ޤ��� ����������ȡ����Υ���åɤ� join �������������Ƥ��ơ� C<$thr-Ejoin()> �θƤӽФ��� I<�֥��å�> ����ޤ��� =item $thr->is_detached() =begin original Returns true if the thread has been detached. =end original ����åɤ� detach ���줿�ʤ鿿���֤��ޤ��� =item threads->is_detached() =begin original Class method that allows a thread to determine whether or not it is detached. =end original ����åɤ� detach ����Ƥ��뤫�ɤ��������Ǥ���褦�ˤ��뤿��� ���饹�᥽�åɤǤ��� =back =head1 THREAD CONTEXT (����åɤΥ���ƥ�����) =begin original As with subroutines, the type of value returned from a thread's entry point function may be determined by the thread's I: list, scalar or void. The thread's context is determined at thread creation. This is necessary so that the context is available to the entry point function via L. The thread may then specify a value of the appropriate type to be returned from C<-Ejoin()>. =end original ���֥롼�����Ʊ�͡�����åɤΥ���ȥ�ݥ���ȴؿ������֤�����ͤη��� ����åɤ� I<����ƥ�����> (�ꥹ�ȡ������顢̵���Τ����줫) �ˤ�ä� ���ꤵ��ޤ��� ����åɤΥ���ƥ����Ȥϥ���åɺ������˷��ꤵ��ޤ��� ����ϡ�����ƥ����Ȥ򥨥�ȥ�ݥ���ȴؿ����� L ��Ȥä����Ѳ�ǽ�ˤ��뤿���ɬ�פǤ��� ���줫�饹��åɤ� C<-Ejoin()> �����֤����Ŭ�ڤʷ����ͤ���ꤷ�ޤ��� =head2 Explicit context (����Ū�ʥ���ƥ�����) =begin original Because thread creation and thread joining may occur in different contexts, it may be desirable to state the context explicitly to the thread's entry point function. This may be done by calling C<-Ecreate()> with a hash reference as the first argument: =end original ����åɤκ����ȥ���åɤ� join �ϰۤʤä�����ƥ����Ȥ� �Ԥ��뤫�⤷��ʤ��Τǡ�����åɤΥ���ȥ�ݥ���ȴؿ�������Ū�� ����ƥ����Ȥ�������뤳�Ȥ�˾�ޤ����Ǥ��� ����Ϻǽ�ΰ����Ȥ��ƥϥå����ե���󥹤���ꤷ�� C<-Ecreate()> �� �ƤӽФ����ȤǹԤ��ޤ�: my $thr = threads->create({'context' => 'list'}, \&foo); ... my @results = $thr->join(); =begin original In the above, the threads object is returned to the parent thread in scalar context, and the thread's entry point function C will be called in list (array) context such that the parent thread can receive a list (array) from the C<-Ejoin()> call. (C<'array'> is synonymous with C<'list'>.) =end original ��Ҥξ�硢����åɥ��֥������ȤϿƥ���åɤ˥����饳��ƥ����Ȥ� �֤��졢����åɤΥ���ȥ�ݥ���ȴؿ� C �ϥꥹ��(����)����ƥ����Ȥ� ͽ�������Τǡ��ƥ���åɤ� C<-Ejoin()> �ƤӽФ�����ꥹ��(����)�� �������ޤ��� (C<'array'> �� C<'list'> ��Ʊ����Ǥ���) =begin original Similarly, if you need the threads object, but your thread will not be returning a value (i.e., I context), you would do the following: =end original Ʊ�ͤˡ��⤷����åɥ��֥������Ȥ�ɬ�פ�����ɤ⡢����åɤ��ͤ��֤��ʤ� (�Ĥޤ� I<̵��> ����ƥ�����) ��硢�ʲ��Τ褦�ˤ��ޤ�: my $thr = threads->create({'context' => 'void'}, \&foo); ... $thr->join(); =begin original The context type may also be used as the I in the hash reference followed by a I value: =end original ����ƥ����ȷ��Ϥޤ����ϥå����ե���󥹤� I<����> �˰���³���� I<��> �� �ͤȤ��Ƥ�Ȥ��ޤ�: threads->create({'scalar' => 1}, \&foo); ... my ($thr) = threads->list(); my $result = $thr->join(); =head2 Implicit context (���ۤΥ���ƥ�����) =begin original If not explicitly stated, the thread's context is implied from the context of the C<-Ecreate()> call: =end original ����Ū���������ʤ���硢����åɤΥ���ƥ����Ȥ� C<-Ecreate()> �ƤӽФ��Υ���ƥ����Ȥˤʤ�ޤ�: # Create thread in list context my ($thr) = threads->create(...); # Create thread in scalar context my $thr = threads->create(...); # Create thread in void context threads->create(...); =head2 $thr->wantarray() =begin original This returns the thread's context in the same manner as L. =end original ����� L ��Ʊ����ˡ�ǥ���åɤ� ����ƥ����Ȥ��֤��ޤ��� =head2 threads->wantarray() =begin original Class method to return the current thread's context. This returns the same value as running L inside the current thread's entry point function. =end original ���ߤΥ���åɤΥ���ƥ����Ȥ��֤����饹�᥽�åɤǤ��� ���ߤΥ���åɤΥ���ȥ�ݥ���ȴؿ�����¦�� L ��¹Ԥ���Τ�Ʊ���ͤ��֤��ޤ��� =head1 THREAD STACK SIZE (����åɤΥ����å�������) =begin original The default per-thread stack size for different platforms varies significantly, and is almost always far more than is needed for most applications. On Win32, Perl's makefile explicitly sets the default stack to 16 MB; on most other platforms, the system default is used, which again may be much larger than is needed. =end original �ǥե���ȤΥ���å���Υ����å��������ϥץ�åȥե�����ˤ�ä��礭���ۤʤꡢ �ۤȤ�ɾ�ˤۤȤ�ɤΥ��ץꥱ�������ɬ�פ��̤��Ϥ뤫��¿���Ǥ��� Win32 �Ǥϡ�Perl �� makefile ������Ū�˥ǥե���ȤΥ����å��� 16 MB �� ���ꤷ�Ƥ��ޤ�; ����¾�ΤۤȤ�ɤΥ����ƥ�Ǥϡ������ƥ�Υǥե���Ȥ� �Ȥ��ޤ�������Ϥ�ɬ�פ��̤��Ϥ뤫��¿���Ǥ��� =begin original By tuning the stack size to more accurately reflect your application's needs, you may significantly reduce your application's memory usage, and increase the number of simultaneously running threads. =end original �����å��������򥢥ץꥱ�������Υˡ����ˤ�����Τ�ȿ�Ǥ����뤳�Ȥˤ�ꡢ ���ץꥱ�������Υ�������̤�����������������Ʊ���¹ԥ���åɿ��� ���䤹���Ȥ��Ǥ��뤫�⤷��ޤ��� =begin original Note that on Windows, address space allocation granularity is 64 KB, therefore, setting the stack smaller than that on Win32 Perl will not save any more memory. =end original ���äơ����ɥ쥹�������֤�γ�٤� 64 KB �Ǥ��� Windows �Ǥϡ�Win32 Perl �� �����꾮�����ͤ˥����å������ꤷ�Ƥ���������Ǥ��ʤ����Ȥ� ���դ��Ƥ��������� =over =item threads->get_stack_size(); =begin original Returns the current default per-thread stack size. The default is zero, which means the system default stack size is currently in use. =end original ���ߤΥǥե���ȤΥ���å���Υ����å����������֤��ޤ��� �ǥե���Ȥ� 0 �ǡ�����ϥ����ƥ�Υǥե���ȥ����å��������� �ȤäƤ��뤳�Ȥ򼨤��ޤ��� =item $size = $thr->get_stack_size(); =begin original Returns the stack size for a particular thread. A return value of zero indicates the system default stack size was used for the thread. =end original ����Υ���åɤΥ����å����������֤��ޤ��� �֤��� 0 �ϡ����Υ���åɤǥ����ƥ�ǥե���ȤΥ����å��������� �Ȥ��Ƥ��뤳�Ȥ򼨤��ޤ��� =item $old_size = threads->set_stack_size($new_size); =begin original Sets a new default per-thread stack size, and returns the previous setting. =end original �������ǥե���ȤΥ���å���Υ����å������������ꤷ������������� �֤��ޤ��� =begin original Some platforms have a minimum thread stack size. Trying to set the stack size below this value will result in a warning, and the minimum stack size will be used. =end original �Ǿ�����åɥ����å�������������ץ�åȥե�����⤢��ޤ��� �����ͤ�ꥹ���å��������򾮤������褦�Ȥ���ȷٹ𤬽Фơ��Ǿ� �����å����������Ȥ��ޤ��� =begin original Some Linux platforms have a maximum stack size. Setting too large of a stack size will cause thread creation to fail. =end original ���祹���å��������Τ��� Linux �ץ�åȥե�����⤢��ޤ��� �礭�����륹���å������������ꤹ��ȥ���åɺ����˼��Ԥ��ޤ��� =begin original If needed, C<$new_size> will be rounded up to the next multiple of the memory page size (usually 4096 or 8192). =end original ɬ�פʤ顢C<$new_size> �ϼ��Υ���ڡ���������(���̤�4096 �� 8192)�ܿ��� �ڤ�夲���ޤ��� =begin original Threads created after the stack size is set will then either call C I<(for pthreads platforms)>, or supply the stack size to C I<(for Win32 Perl)>. =end original �����å������������ꤵ�줿��˺��줿����åɤ� C ��ƤӽФ� I<(pthreads �ץ�åȥե������ ���)> �� C �˥����å����������Ϥ��ޤ� I<(Win32 Perl �ξ��)>�� =begin original (Obviously, this call does not affect any currently extant threads.) =end original (���餫�ˡ����θƤӽФ��ϴ���¸�ߤ��륹��åɤˤϱƶ���Ϳ���ޤ���) =item use threads ('stack_size' => VALUE); =begin original This sets the default per-thread stack size at the start of the application. =end original ����ϥ��ץꥱ�������γ��ϻ��˥����å�ñ�̤Υǥե���ȤΥ����å��������� ���ꤷ�ޤ��� =item $ENV{'PERL5_ITHREADS_STACK_SIZE'} =begin original The default per-thread stack size may be set at the start of the application through the use of the environment variable C: =end original �ǥե���ȤΥ���å���Υ����å��������ϴĶ��ѿ� C ��Ȥäƥ��ץꥱ�������γ��ϻ�������Ǥ��ޤ�: PERL5_ITHREADS_STACK_SIZE=1048576 export PERL5_ITHREADS_STACK_SIZE perl -e'use threads; print(threads->get_stack_size(), "\n")' =begin original This value overrides any C parameter given to C. Its primary purpose is to permit setting the per-thread stack size for legacy threaded applications. =end original �����ͤ� C ��Ϳ������ C �����Ǿ�񤭤Ǥ��ޤ��� �����Ū�ϥ쥬�����ʥ���åɥ��ץꥱ�������ǥ���å���Υ����å��������� ����Ǥ���褦�ˤ��뤳�ȤǤ��� =item threads->create({'stack_size' => VALUE}, FUNCTION, ARGS) =begin original To specify a particular stack size for any individual thread, call C<-Ecreate()> with a hash reference as the first argument: =end original �ġ��Υ���åɤθ��̤Υ����å�����������ꤹ��ˤϡ��ǽ�ΰ����Ȥ��� �ϥå����ե���󥹤���ꤷ�� C<-Ecreate()> ��ƤӽФ��ޤ�: my $thr = threads->create({'stack_size' => 32*4096}, \&foo, @args); =item $thr2 = $thr1->create(FUNCTION, ARGS) =begin original This creates a new thread (C<$thr2>) that inherits the stack size from an existing thread (C<$thr1>). This is shorthand for the following: =end original ����ϴ���¸�ߤ��륹��å� (C<$thr1>) ���饹���å���������Ѿ����ƿ����� ����å� (C<$thr2>) ��������ޤ��� ����ϰʲ��Τ�Τ�û�̷��Ǥ�: my $stack_size = $thr1->get_stack_size(); my $thr2 = threads->create({'stack_size' => $stack_size}, FUNCTION, ARGS); =back =head1 THREAD SIGNALLING (����åɤȥ����ʥ�) =begin original When safe signals is in effect (the default behavior - see L for more details), then signals may be sent and acted upon by individual threads. =end original �����ʥ����ʥ뤬ͭ���ʤȤ� (�ǥե���Ȥο����񤤤Ǥ� - ����ʤ� �ܺ٤ˤĤ��Ƥ� L �򻲾Ȥ��Ƥ�������)�������ʥ�� ���줾��Υ���åɤ��Ф���������ư��ޤ��� =over 4 =item $thr->kill('SIG...'); =begin original Sends the specified signal to the thread. Signal names and (positive) signal numbers are the same as those supported by L. For example, 'SIGTERM', 'TERM' and (depending on the OS) 15 are all valid arguments to C<-Ekill()>. =end original ���ꤵ�줿�����ʥ�򥹥�åɤ�����ޤ��� �����ʥ�̾��(����)�����ʥ��ֹ�� L �� �б����Ƥ����Τ�Ʊ���Ǥ��� �㤨�С�'SIGTERM', 'TERM' �� (OS �˰�¸���ޤ���) 15 ������ C<-Ekill()> �ؤ������ʰ����Ǥ��� =begin original Returns the thread object to allow for method chaining: =end original �᥽�åɥ������󤬤Ǥ���褦�ˡ�����åɥ��֥������Ȥ��֤��ޤ�: $thr->kill('SIG...')->join(); =back =begin original Signal handlers need to be set up in the threads for the signals they are expected to act upon. Here's an example for I a thread: =end original �����ʥ�ϥ�ɥ���б����뤳�Ȥ����ꤷ�Ƥ��륷���ʥ���Ф��ƥ���åɤ� ���ꤵ���ɬ�פ�����ޤ��� �ʲ��ϥ���åɤ� I<����󥻥뤹��> ��Ǥ�: use threads; sub thr_func { # Thread 'cancellation' signal handler $SIG{'KILL'} = sub { threads->exit(); }; ... } # Create a thread my $thr = threads->create('thr_func'); ... # Signal the thread to terminate, and then detach # it so that it will get cleaned up automatically $thr->kill('KILL')->detach(); =begin original Here's another simplistic example that illustrates the use of thread signalling in conjunction with a semaphore to provide rudimentary I and I capabilities: =end original �ʲ��ϴ���Ū�� I<����> �� I<�Ƴ�> �ε�ǽ���󶡤��뤿��˥���åɤ� �����ʥ�򥻥ޥե����Ȥ߹�碌���Ȥ����򼨤������ñ�㲽���줿�⤦��Ĥ� ��Ǥ�: use threads; use Thread::Semaphore; sub thr_func { my $sema = shift; # Thread 'suspend/resume' signal handler $SIG{'STOP'} = sub { $sema->down(); # Thread suspended $sema->up(); # Thread resumes }; ... } # Create a semaphore and pass it to a thread my $sema = Thread::Semaphore->new(); my $thr = threads->create('thr_func', $sema); # Suspend the thread $sema->down(); $thr->kill('STOP'); ... # Allow the thread to continue $sema->up(); =begin original CAVEAT: The thread signalling capability provided by this module does not actually send signals via the OS. It I signals at the Perl-level such that signal handlers are called in the appropriate thread. For example, sending C<$thr-Ekill('STOP')> does not actually suspend a thread (or the whole process), but does cause a C<$SIG{'STOP'}> handler to be called in that thread (as illustrated above). =end original �ٹ�: ���Υ⥸�塼��ˤ�ä��󶡤���Ƥ��륹��åɤؤΥ����ʥ뵡ǽ�� �ºݤˤ� OS ��ͳ�ǥ����ʥ�����äƤ��ޤ��� �����ʥ�ϥ�ɥ餬Ŭ�ڤʥ���åɤǸƤӽФ����褦�� Perl ��٥�ǥ����ʥ�� I<���ߥ�졼��> ���Ƥ��ޤ��� �㤨�С�C<$thr-Ekill('STOP')> �ϼºݤˤϥ���å�(�ޤ��ϥץ���������)�� ��ߤ����ޤ��󤬡�(��Ҥ����褦��) �оݤΥ���åɤ� C<$SIG{'STOP'}> �ϥ�ɥ餬�ƤӽФ���ޤ��� =begin original As such, signals that would normally not be appropriate to use in the C command (e.g., C) are okay to use with the C<-Ekill()> method (again, as illustrated above). =end original ���Τ��ᡢ���̤� C ���ޥ�ɤǤλ��Ѥ�Ŭ�ڤǤϤʤ��褦�ʥ����ʥ� (�㤨�� C)) �� C<-Ekill()> �᥽�åɤǻȤäƤ� (�ƤӾ�Ҥ����褦��)���ꤢ��ޤ��� =begin original Correspondingly, sending a signal to a thread does not disrupt the operation the thread is currently working on: The signal will be acted upon after the current operation has completed. For instance, if the thread is I on an I/O call, sending it a signal will not cause the I/O call to be interrupted such that the signal is acted up immediately. =end original Ʊ�ͤˡ�����åɤ˥����ʥ�����äƤ⥹��åɤ����������Ƥ������� ˸�����ޤ���: �����ʥ�ϸ��ߤν�������λ������˽�������ޤ��� �㤨�С�����åɤ� I/O �ƤӽФ��� I<�ǤޤäƤ���> �ʤ顢�����ʥ뤬ľ���� ���������褦�� I/O �ƤӽФ������ǤϤ��ޤ��� =begin original Sending a signal to a terminated thread is ignored. =end original ��λ��������åɤؤΥ����ʥ�������̵�뤵��ޤ��� =head1 WARNINGS (�ٹ�) =over 4 =item Perl exited with active threads: =begin original If the program exits without all threads having either been joined or detached, then this warning will be issued. =end original ���ƤΥ���åɤ� join ����뤫 detach ��������˥ץ�����ब��λ������硢 ���ηٹ�ȯ�����ޤ��� =begin original NOTE: If the I
thread exits, then this warning cannot be suppressed using C as suggested below. =end original ����: I
����åɤ�¸�ߤ��Ƥ���ʤ顢��˼������Ƥ���褦�ˤ��ηٹ�� C ��Ȥä������Ǥ��ޤ��� =item Thread creation failed: pthread_create returned # =begin original See the appropriate I page for C to determine the actual cause for the failure. =end original ���Ԥμºݤθ�������ꤹ��ˤ� C ��Ŭ�ڤ� I �ڡ����� ���Ȥ��Ƥ��������� =item Thread # terminated abnormally: ... =begin original A thread terminated in some manner other than just returning from its entry point function, or by using Cexit()>. For example, the thread may have terminated because of an error, or by using C. =end original ����åɤ�ñ�˥���ȥ�ݥ���ȴؿ������֤ä��� Cexit()> �� �Ȥä��ʳ��β��餫����ˡ�ǽ�λ���ޤ����� �㤨�С����顼�� C �λ��Ѥˤ�äƥ���åɤ���λ���ޤ����� =item Using minimum thread stack size of # =begin original Some platforms have a minimum thread stack size. Trying to set the stack size below this value will result in the above warning, and the stack size will be set to the minimum. =end original ���㥹��åɥ����å�������������ץ�åȥե�����⤢��ޤ��� �����å��������򤽤��Ͱʲ������ꤷ�褦�Ȥ���Ȥ��ηٹ𤬽Фơ� �����å��������ϺǾ��ͤ����ꤵ��ޤ��� =item Thread creation failed: pthread_attr_setstacksize(I) returned 22 =begin original The specified I exceeds the system's maximum stack size. Use a smaller value for the stack size. =end original ���ꤵ�줿 I �������ƥ�κ��祹���å���������Ķ���Ƥ��ޤ��� �����å��������Ȥ��Ƥ�꾮�����ͤ�ȤäƤ��������� =back =begin original If needed, thread warnings can be suppressed by using: =end original �⤷ɬ�פʤ顢����åɤηٹ�ϰʲ��Τ�Τ�: no warnings 'threads'; =begin original in the appropriate scope. =end original Ŭ�ڤʥ������פǻȤ����Ȥ������Ǥ��ޤ��� =head1 ERRORS (���顼) =over 4 =item This Perl not built to support threads =begin original The particular copy of Perl that you're trying to use was not built using the C configuration option. =end original �Ȥ����Ȥ��Ƥ��� Perl �� C ���ꥪ�ץ�����Ȥä� �ӥ�ɤ���Ƥ��ޤ��� =begin original Having threads support requires all of Perl and all of the XS modules in the Perl installation to be rebuilt; it is not just a question of adding the L module (i.e., threaded and non-threaded Perls are binary incompatible.) =end original ����å��б��ˤ��뤿��ˤ� Perl �����Ƥ� Perl ���󥹥ȡ�������Ƥ� XS �⥸�塼���ƥӥ�ɤ���ɬ�פ�����ޤ�; ����� L �⥸�塼��� �ɲä��뤿������ǤϤ���ޤ��� (�Ĥޤꡢ����å��б� Perl �����б� Perl �� �Х��ʥ�ߴ���������ޤ���) =item Cannot change stack size of an existing thread =begin original The stack size of currently extant threads cannot be changed, therefore, the following results in the above error: =end original ���ߴ��ˤ��륹��åɤΥ����å����������ѹ��Ǥ��ʤ��Τǡ��ʲ��Τ褦�ʤ�Τ� ��ҤΥ��顼�ˤʤ�ޤ�: $thr->set_stack_size($size); =item Cannot signal threads without safe signals =begin original Safe signals must be in effect to use the C<-Ekill()> signalling method. See L for more details. =end original C<-Ekill()> �����ʥ�᥽�åɤ�Ȥ��ˤϰ����ʥ����ʥ뤬 ͭ���Ǥʤ���Фʤ�ޤ��� ����ʤ�ܺ٤ˤĤ��Ƥ� L �򻲾Ȥ��Ƥ��������� =item Unrecognized signal name: ... =begin original The particular copy of Perl that you're trying to use does not support the specified signal being used in a C<-Ekill()> call. =end original �Ȥ����Ȥ��Ƥ��� Perl �� C<-Ekill()> �ƤӽФ��ǻȤ����Ȥ��Ƥ��륷���ʥ�� �б����Ƥ��ޤ��� =back =head1 BUGS AND LIMITATIONS (�Х�������) =begin original Before you consider posting a bug report, please consult, and possibly post a message to the discussion forum to see if what you've encountered is a known problem. =end original �Х�������Ƥ��뤳�Ȥ�ͤ������ˡ��ޤ����̤��Ƥ�������; �����ƤǤ���� ����������Τ����Τ����꤫�ɤ����򸫤뤿��˵����ե������˥�å������� ��Ƥ��Ƥ��������� =over =item Thread-safe modules (����åɥ����դʥ⥸�塼��) =begin original See L when creating modules that may be used in threaded applications, especially if those modules use non-Perl data, or XS code. =end original ����å��б����ץꥱ�������ǻȤ��뤫�⤷��ʤ��⥸�塼�����Ȥ��� �Ȥ��˥⥸�塼�뤬�� Perl �ǡ����� XS �����ɤ�ȤäƤ���Ȥ��ϡ� L �򻲾Ȥ��Ƥ��������� =item Using non-thread-safe modules (�󥹥�åɥ����դʥ⥸�塼���Ȥ�) =begin original Unfortunately, you may encounter Perl modules that are not I. For example, they may crash the Perl interpreter during execution, or may dump core on termination. Depending on the module and the requirements of your application, it may be possible to work around such difficulties. =end original ��ǰ�ʤ��顢I<����åɥ�����> �ǤϤʤ� Perl �⥸�塼��� �������뤫�⤷��ޤ��� �㤨�С��¹���� Perl ���󥿥ץ꥿������å��夷���ꡢ��������פ��� ��λ�����ꤹ�뤫�⤷��ޤ��� �⥸�塼��ȥ��ץꥱ��������ɬ�׻���˰�¸���ơ����Τ褦������� ����Ǥ��뤳�Ȥ�����ޤ��� =begin original If the module will only be used inside a thread, you can try loading the module from inside the thread entry point function using C (and C if needed): =end original �⥸�塼�뤬����åɤ���Ǥ����Ȥ��Ƥ���ʤ顢����åɥ���ȥ�ؿ��� ��¦���� C (�����ɬ�פʤ� C) ��Ȥäƥ⥸�塼��� �ɤ߹���ǤߤƤ�������: sub thr_func { require Unsafe::Module # Unsafe::Module->import(...); .... } =begin original If the module is needed inside the I
thread, try modifying your application so that the module is loaded (again using C and C<-Eimport()>) after any threads are started, and in such a way that no other threads are started afterwards. =end original �⥸�塼�뤬 I
����åɤ���¦��ɬ�פʤ顢����åɤ򳫻Ϥ��Ƥ��� (�Ƥ� C �� C<-Eimport()> ��Ȥä�) �⥸�塼�뤬 �ɤ߹��ޤ��褦�ˡ������Ƥ��θ�¾�Υ���åɤ����Ϥ��ʤ��褦�� ���ץꥱ�������������ƤߤƤ��������� =begin original If the above does not work, or is not adequate for your application, then file a bug report on L against the problematic module. =end original ��ҤΤ�Τ�ư��ʤ��������ץꥱ��������Ŭ�ڤǤʤ��ʤ顢����Τ��� �⥸�塼����Ф��� L �˥Х����� ��Ͽ���Ƥ��������� =item Current working directory (�����ȥ���󥰥ǥ��쥯�ȥ�) =begin original On all platforms except MSWin32, the setting for the current working directory is shared among all threads such that changing it in one thread (e.g., using C) will affect all the threads in the application. =end original MSWin32 �ʳ������ƤΥץ�åȥե�����Ǥϡ������ȥ���󥰥ǥ��쥯�ȥ�� ��������ƤΥ���åɤǶ�ͭ�����Τǡ����륹��åɤǤ�����ѹ����� (�Ĥޤ� C ��Ȥ�) �ȥ��ץꥱ�����������ƤΥ���åɤ� �ƶ����ޤ��� =begin original On MSWin32, each thread maintains its own the current working directory setting. =end original MSWin32 �Ǥϡ����줾��Υ����ȥ���󥰥ǥ��쥯�ȥ�������ȼ��� �������Ƥ��ޤ��� =item Environment variables (�Ķ��ѿ�) =begin original Currently, on all platforms except MSWin32, all I calls (e.g., using C or back-ticks) made from threads use the environment variable settings from the I
thread. In other words, changes made to C<%ENV> in a thread will not be visible in I calls made by that thread. =end original ���ߤΤȤ�����MSWin32 �ʳ������ƤΥץ�åȥե�����Ǥϡ� ����åɤˤ�äƺ��줿 (C �ޤ��ϵե������Ȥˤ��) ���Ƥ� I �ƤӽФ��� I
����åɤδĶ��ѿ������Ȥ��ޤ��� ����������ȡ�����åɤǹԤä� C<%ENV> �ؤ��ѹ��ϡ����Υ���åɤǺ��줿 I �ƤӽФ��Ǥϸ����ޤ��� =begin original To work around this, set environment variables as part of the I call. For example: =end original �������򤹤�ˤϡ�I �ƤӽФ��ΰ����Ȥ��ƴĶ��ѿ��򥻥åȤ��ޤ��� �㤨��: my $msg = 'hello'; system("FOO=$msg; echo \$FOO"); # Outputs 'hello' to STDOUT =begin original On MSWin32, each thread maintains its own set of environment variables. =end original MSWin32 �Ǥϡ��ƥ���åɤǤ��ȼ��δĶ��ѿ������������ޤ��� =item Parent-child threads (��-�ҥ���å�) =begin original On some platforms, it might not be possible to destroy I threads while there are still existing I threads. =end original �ץ�åȥե�����ˤ�äƤϡ�I<��> ����åɤ��ޤ�¸�ߤ��Ƥ���֤� I<��> ����åɤ��˲����뤳�Ȥ��Ǥ��ʤ����Ȥ�����ޤ��� =item Creating threads inside special blocks (�ü�֥��å�����ǥ���åɤ���) =begin original Creating threads inside C, C or C blocks should not be relied upon. Depending on the Perl version and the application code, results may range from success, to (apparently harmless) warnings of leaked scalar, or all the way up to crashing of the Perl interpreter. =end original C, C, C �֥��å�����¦�ǥ���åɤ�������뤳�Ȥ� ���ꤹ��٤��ǤϤ���ޤ��� Perl �С������ȥ��ץꥱ������󥳡��ɤ˰�¸���ơ���������(�����餯�� ̵����)�꡼������������ηٹ�Perl ���󥿥ץ꥿�Υ���å���ޤǤ��ޤ��ޤ� ��̤Ȥʤ�ޤ��� =item Unsafe signals (�����Ǥʤ������ʥ�) =begin original Since Perl 5.8.0, signals have been made safer in Perl by postponing their handling until the interpreter is in a I state. See L and L for more details. =end original Perl 5.8.0 ���顢���󥿥ץ꥿�� I<������> ���֤ˤʤ�ޤǥ����ʥ����� ������뤳�Ȥǥ����ʥ�Ϥ������ˤʤ�ޤ����� ����ʤ�ܺ٤ˤĤ��Ƥ� L �� L �򻲾Ȥ��Ƥ��������� =begin original Safe signals is the default behavior, and the old, immediate, unsafe signalling behavior is only in effect in the following situations: =end original �����ʥ����ʥ�ϥǥե���Ȥο����񤤤ǡ��Ť���¨���ǡ������Ǥʤ������ʥ�� �����񤤤ϰʲ��ξ����ǤΤ�ͭ���Ǥ��� =over 4 =item * Perl has been built with C (see C). (Perl �� C �ǥӥ�ɤ���Ƥ���(C ����)��) =item * The environment variable C is set to C (see L). (�Ķ��ѿ� C �� C �����ꤵ��Ƥ��� (L ����)��) =item * The module L is used. (L �⥸�塼�뤬�Ȥ��Ƥ��롣) =back =begin original If unsafe signals is in effect, then signal handling is not thread-safe, and the C<-Ekill()> signalling method cannot be used. =end original �����Ǥʤ������ʥ뤬ͭ���ξ�硢�����ʥ�ΰ����ϥ���åɥ����դǤϤʤ��� C<-Ekill()> �����ʥ�᥽�åɤϻȤ��ޤ��� =item Returning closures from threads (����åɤ��饯����������֤�) =begin original Returning closures from threads should not be relied upon. Depending of the Perl version and the application code, results may range from success, to (apparently harmless) warnings of leaked scalar, or all the way up to crashing of the Perl interpreter. =end original ����åɤ��饯����������֤����Ȥ��ꤹ��٤��ǤϤ�������� Perl �С������ȥ��ץꥱ������󥳡��ɤ˰�¸���ơ���������(�����餯�� ̵����)�꡼������������ηٹ�Perl ���󥿥ץ꥿�Υ���å���ޤǤ��ޤ��ޤ� ��̤Ȥʤ�ޤ��� =item Returning objects from threads (����åɤ��饪�֥������Ȥ��֤�) =begin original Returning objects from threads does not work. Depending on the classes involved, you may be able to work around this by returning a serialized version of the object (e.g., using L or L), and then reconstituting it in the joining thread. =end original ����åɤ��饪�֥������Ȥ��֤��Τ�ư��ޤ��� �Ȥ����饹�˰�¸���ơ�(�㤨�� L �� L ��Ȥä�) ľ�󲽤��줿���֥������Ȥ��֤��ơ�join ��������åɤǤ����ƹ������뤳�Ȥ� ��������Ǥ��뤳�Ȥ�����ޤ��� =item Perl Bugs and the CPAN Version of L (Perl �ΥХ��� CPAN �Ǥ� L) =begin original Support for threads extends beyond the code in this module (i.e., F and F), and into the Perl interpreter itself. Older versions of Perl contain bugs that may manifest themselves despite using the latest version of L from CPAN. There is no workaround for this other than upgrading to the latest version of Perl. =end original ����åɤ��б��� ���Υ⥸�塼�� (�Ĥޤ� F �� F) �Υ����ɤ�Ķ���� Perl ���󥿥ץ꥿���Ȥ˳�ĥ����ޤ��� ���Ť��С������� Perl �ˤ� CPAN ����ǿ��Ǥ� L ��ȤäƤ���ˤ� �ؤ�餺��ʬ���Ȥ򼨤��Ȥ����Х�������ޤ��� Perl ��ǿ��Ǥ˥��åץ��졼�ɤ���ʳ��˲�����ˡ�Ϥ���ޤ��� =begin original Even with the latest version of Perl, it is known that certain constructs with threads may result in warning messages concerning leaked scalars or unreferenced scalars. However, such warnings are harmless, and may safely be ignored. =end original �ǿ��Ǥ� Perl �Ǥ⡢����åɤȤ����ι�¤�ϥ꡼������������� ���Ȥ���Ƥ��ʤ���������Ѥ���ٹ��å��������Ф뤳�Ȥ�����ޤ��� �����������Τ褦�ʷٹ��̵���ǡ�������̵��Ǥ��ޤ��� =back =head1 REQUIREMENTS (ɬ�׾��) =begin original Perl 5.8.0 or later =end original Perl 5.8.0 �ʹ� =head1 SEE ALSO =begin original L Discussion Forum on CPAN: L =end original CPAN �� L �ǥ������å����ե������: L =begin original Annotated POD for L: L =end original L �������դ� POD: L =begin original Source repository: L =end original ��������ݥ��ȥ�: L L, L =begin original L and L =end original L �� L =begin original Perl threads mailing list: L =end original Perl ����åɥ᡼��󥰥ꥹ��: L =begin original Stack size discussion: L =end original �����å��������ε���: L =head1 AUTHOR Artur Bergman Esky AT crucially DOT netE threads is released under the same license as Perl. CPAN version produced by Jerry D. Hedden =head1 ACKNOWLEDGEMENTS Richard Soderberg Eperl AT crystalflame DOT netE - Helping me out tons, trying to find reasons for races and other weird bugs! Simon Cozens Esimon AT brecon DOT co DOT ukE - Being there to answer zillions of annoying questions Rocco Caputo Etroc AT netrus DOT netE Vipul Ved Prakash Email AT vipul DOT netE - Helping with debugging Dean Arnold Edarnold AT presicient DOT comE - Stack size API =begin meta Translate: �ޤ��ޤ� Update: Kentaro Shirakata (5.8.4, 1.67-) Status: completed =end meta =cut