forksDrop-in replacement for Perl threads using fork() | |
Download |
forks Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Eric Rybski
- Publisher web site:
- http://search.cpan.org/~rybskej/
forks Tags
forks Description
Drop-in replacement for Perl threads using fork() forks is a Perl module that allows a developer to use threads without having to have a threaded perl, or to even run 5.8.0 or higher.SYNOPSIS use forks; #ALWAYS LOAD AS FIRST MODULE, if possible use warnings; my $thread = threads->new( sub { # or ->create or async() print "Hello world from a thread "; } ); $thread->join; $thread = threads->new( { 'context' => 'list' }, sub { print "Thread is expected to return a list "; return (1, 'abc', 5); } my @result = $thread->join(); threads->detach; $thread->detach; my $tid = $thread->tid; my $owntid = threads->tid; my $self = threads->self; my $threadx = threads->object( $tidx ); my @running = threads->list(threads::running); $_->join() foreach (threads->list(threads::joinable)); $_->join foreach threads->list; #block until all threads done unless (fork) { threads->isthread; # could be used a child-init Apache handler } # Enable debugging use forks qw(debug); threads->debug( 1 ); # Stringify thread objects use forks qw(stringify); # Check state of a thread my $thr = threads->new( ... ); if ($thr->is_running()) { print "Thread $thr running "; #prints "Thread 1 running" } # Send a signal to a thread $thr->kill('SIGUSR1'); # Manual deadlock detection if ($thr->is_deadlocked()) { print "Thread $thr is currently deadlocked! "; } # Use forks as a drop-in replacement for an ithreads application perl -Mforks -Mforks::shared threadapplication Requirements: · Perl
forks Related Software