|
NAMEThread::Suspend - Suspend and resume operations for threadsVERSIONThis document describes Thread::Suspend version 1.23SYNOPSISuse Thread::Suspend 'SIGUSR1'; # Set the suspension signal use Thread::Suspend; # Defaults to 'STOP' $thr->suspend(); # Suspend a thread threads->suspend(); # Suspend all non-detached threads threads->suspend($thr, $tid, ...); # Suspend multiple threads using # objects or TIDs $thr->is_suspended(); # Returns suspension count threads->is_suspended(); # Returns list of all suspended threads $thr->resume(); # Resume a thread threads->resume(); # Resume all threads threads->resume($thr, $tid, ...); # Resume multiple threads DESCRIPTIONThis module adds suspend and resume operations for threads.Suspensions are cumulative, and need to be matched by an equal number of resume calls. DeclarationThis module must be imported prior to any threads being created.Suspension is accomplished via a signal handler which is used by all threads on which suspend operations are performed. The signal for this operation can be specified when this module is declared, and defaults to "SIGSTOP". Consequently, the application and its threads must not specify some other handler for use with the suspend signal.
Methods
CAVEATSSubject to the limitations of "THREAD SIGNALLING" in threads.A thread that has been suspended will not respond to any other signals or commands until its suspension count is brought back to zero via resume calls. Any locks held by a thread when it is suspended will remain in effect. To alleviate this potential problem, lock any such variables as part of a limited scope that also contains the suspension call: { lock($var); $thr->suspend(); } Calling "->resume()" on an non-suspended thread is ignored. Detached threads can only be operated upon if their threads object is used. For example, the following works: my $thr = threads->create(...); $thr->detach(); ... $thr->suspend(); # or threads->suspend($thr); ... $thr->resume(); # or threads->resume($thr); Threads that have finished execution are, for the most part, ignored by this module. REQUIREMENTSPerl 5.8.0 or laterthreads 1.39 or later threads::shared 1.01 or later Test::More 0.50 or later (for installation) SEE ALSOThread::Suspend on MetaCPAN: <https://metacpan.org/release/Thread-Suspend>Code repository: <https://github.com/jdhedden/Thread-Suspend> threads, threads::shared Sample code in the examples directory of this distribution on CPAN. AUTHORJerry D. Hedden, <jdhedden AT cpan DOT org>COPYRIGHT AND LICENSECopyright 2006 - 2009 Jerry D. Hedden. All rights reserved.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |