Lines Matching +full:fine +full:- +full:tuning

49                     threads->set_stack_size($arg);
79 threads->set_stack_size($ENV{'PERL5_ITHREADS_STACK_SIZE'});
97 Carp::croak('Usage: threads->exit(status)');
100 $class->set_thread_exit_only(1);
104 # 'Constant' args for threads->list()
112 # 'async' is a function alias for the 'threads->create()' method
133 threads - Perl interpreter-based threads
141 The "interpreter-based threads" provided by Perl are not the fast, lightweight
146 The use of interpreter-based threads in perl is officially
160 my $thr = threads->create('start_thread', 'argument');
161 $thr->join();
163 threads->create(sub { print("I am a thread\n"); })->join();
166 $thr2->join();
167 if (my $err = $thr2->error()) {
172 my ($thr) = threads->create(sub { return (qw/a b c/); });
174 my $thr = threads->create({'context' => 'list'},
176 my @results = $thr->join();
178 $thr->detach();
181 $thr = threads->self();
182 $thr = threads->object($tid);
185 $tid = threads->tid();
186 $tid = $thr->tid();
190 threads->yield();
193 # Lists of non-detached threads
194 my @threads = threads->list();
195 my $thread_count = threads->list();
197 my @running = threads->list(threads::running);
198 my @joinable = threads->list(threads::joinable);
206 $stack_size = threads->get_stack_size();
207 $old_size = threads->set_stack_size(32*4096);
210 my $thr = threads->create({ 'context' => 'list',
216 my $wantarray = $thr->wantarray();
219 if ($thr->is_running()) {
222 if ($thr->is_joinable()) {
223 $thr->join();
227 $thr->kill('SIGUSR1');
230 threads->exit();
256 non-threaded Perls:
269 =item $thr = threads->create(FUNCTION, ARGS)
278 my $thr = threads->create('func_name', ...);
280 my $thr = threads->create(sub { ... }, ...);
282 my $thr = threads->create(\&func, ...);
284 The C<-E<gt>new()> method is an alias for C<-E<gt>create()>.
286 =item $thr->join()
289 the thread finishes, C<-E<gt>join()> will return the return value(s) of the
292 The context (void, scalar or list) for the return value(s) for C<-E<gt>join()>
296 my ($thr1) = threads->create(sub {
301 my $thr1 = threads->create({'context' => 'list'},
307 my @res1 = $thr1->join();
310 my $thr2 = threads->create(sub {
315 my $res2 = $thr2->join();
318 my $thr3 = threads->create({'void' => 1},
321 $thr3->join();
328 Calling C<-E<gt>join()> or C<-E<gt>detach()> on an already joined thread will
331 =item $thr->detach()
340 Calling C<-E<gt>join()> or C<-E<gt>detach()> on an already detached thread
343 =item threads->detach()
347 =item threads->self()
351 =item $thr->tid()
356 =item threads->tid()
368 my $thr = threads->create(...);
371 =item threads->object($tid)
375 then this call works the same as C<-E<gt>self()>. Otherwise, returns C<undef>
379 =item threads->yield()
388 =item threads->list()
390 =item threads->list(threads::all)
392 =item threads->list(threads::running)
394 =item threads->list(threads::joinable)
397 list of all non-joined, non-detached I<threads> objects. In a scalar context,
401 non-joined, non-detached I<threads> objects that are still running.
404 non-joined, non-detached I<threads> objects that have finished running (i.e.,
405 for which C<-E<gt>join()> will not I<block>).
407 =item $thr1->equal($thr2)
426 semicolon after the closing brace. Like C<threads-E<gt>create()>, C<async>
429 =item $thr->error()
435 =item $thr->_handle()
445 to provide other (XS-based) thread modules with the capability to access, and
449 =item threads->_handle()
463 =item threads->exit()
466 C<threads-E<gt>exit()>. This will cause the thread to return C<undef> in a
471 =item threads->exit(status)
473 When called from a thread, this behaves like C<threads-E<gt>exit()> (i.e., the
494 threads->exit() if threads->can('exit'); # Thread friendly
501 C<threads-E<gt>exit()>. In other words, with this setting, calling C<exit()>
509 =item threads->create({'exit' => 'thread_only'}, ...)
514 =item $thr->set_thread_exit_only(boolean)
523 =item threads->set_thread_exit_only(boolean)
538 =item $thr->is_running()
543 =item $thr->is_joinable()
547 to C<$thr-E<gt>join()> will not I<block>.
549 =item $thr->is_detached()
553 =item threads->is_detached()
566 the appropriate type to be returned from C<-E<gt>join()>.
572 function. This may be done by calling C<-E<gt>create()> with a hash reference
575 my $thr = threads->create({'context' => 'list'}, \&foo);
577 my @results = $thr->join();
582 the C<-E<gt>join()> call. (C<'array'> is synonymous with C<'list'>.)
587 my $thr = threads->create({'context' => 'void'}, \&foo);
589 $thr->join();
594 threads->create({'scalar' => 1}, \&foo);
596 my ($thr) = threads->list();
597 my $result = $thr->join();
602 of the C<-E<gt>create()> call:
605 my ($thr) = threads->create(...);
608 my $thr = threads->create(...);
611 threads->create(...);
613 =head2 $thr->wantarray()
618 =head2 threads->wantarray()
626 The default per-thread stack size for different platforms varies
632 By tuning the stack size to more accurately reflect your application's needs,
642 =item threads->get_stack_size();
644 Returns the current default per-thread stack size. The default is zero, which
647 =item $size = $thr->get_stack_size();
652 =item $old_size = threads->set_stack_size($new_size);
654 Sets a new default per-thread stack size, and returns the previous setting.
674 This sets the default per-thread stack size at the start of the application.
678 The default per-thread stack size may be set at the start of the application
683 perl -e'use threads; print(threads->get_stack_size(), "\n")'
686 primary purpose is to permit setting the per-thread stack size for legacy
689 =item threads->create({'stack_size' => VALUE}, FUNCTION, ARGS)
692 C<-E<gt>create()> with a hash reference as the first argument:
694 my $thr = threads->create({'stack_size' => 32*4096},
697 =item $thr2 = $thr1->create(FUNCTION, ARGS)
702 my $stack_size = $thr1->get_stack_size();
703 my $thr2 = threads->create({'stack_size' => $stack_size},
710 When safe signals is in effect (the default behavior - see L</"Unsafe signals">
716 =item $thr->kill('SIG...');
721 (depending on the OS) 15 are all valid arguments to C<-E<gt>kill()>.
725 $thr->kill('SIG...')->join();
737 $SIG{'KILL'} = sub { threads->exit(); };
743 my $thr = threads->create('thr_func');
749 $thr->kill('KILL')->detach();
764 $sema->down(); # Thread suspended
765 $sema->up(); # Thread resumes
772 my $sema = Thread::Semaphore->new();
773 my $thr = threads->create('thr_func', $sema);
776 $sema->down();
777 $thr->kill('STOP');
782 $sema->up();
785 actually send signals via the OS. It I<emulates> signals at the Perl-level
787 sending C<$thr-E<gt>kill('STOP')> does not actually suspend a thread (or the
793 C<-E<gt>kill()> method (again, as illustrated above).
823 point function, or by using C<threads-E<gt>exit()>. For example, the thread
856 L<threads> module (i.e., threaded and non-threaded Perls are binary
864 $thr->set_stack_size($size);
868 Safe signals must be in effect to use the C<-E<gt>kill()> signalling method.
874 specified signal being used in a C<-E<gt>kill()> call.
886 =item Thread-safe modules
889 be used in threaded applications, especially if those modules use non-Perl
892 =item Using non-thread-safe modules
894 Unfortunately, you may encounter Perl modules that are not I<thread-safe>.
906 # Unsafe::Module->import(...);
913 C<-E<gt>import()>) after any threads are started, and in such a way that no
922 can lead to ever-increasing growth in the memory footprint of the Perl
924 C<-E<gt>join()> or C<-E<gt>detach()> them, for long-lived applications, it is
944 thread-safe locale functions, threads can be used, with some caveats.
946 with POSIX 2008. See L<perllocale/Multi-threaded operation>.
957 and then pass to threads->create() a sub that closes over C<$foo>. Then, in
970 C<system()> or back-ticks) made from threads use the environment variable
994 my $thr = threads->create(sub {
995 threads->yield();
1008 $SIG{ALRM} = sub { $thr->kill('ALRM') };
1012 =item Parent-child threads
1029 =item * Perl has been built with C<PERL_OLD_SIGNALS> (see S<C<perl -V>>).
1038 If unsafe signals is in effect, then signal handling is not thread-safe, and
1039 the C<-E<gt>kill()> signalling method cannot be used.
1046 creation. This works fine for most kinds of value, including arrays,
1074 during a C<-E<gt>join()> call, or at program termination).
1136 L<https://github.com/Dual-Life/threads>
1163 Richard Soderberg E<lt>perl AT crystalflame DOT netE<gt> -
1166 Simon Cozens E<lt>simon AT brecon DOT co DOT ukE<gt> -
1171 Vipul Ved Prakash E<lt>mail AT vipul DOT netE<gt> -
1174 Dean Arnold E<lt>darnold AT presicient DOT comE<gt> -