NAME

forks::shared - drop-in replacement for Perl threads::shared with forks()

SYNOPSIS

use forks;
use forks::shared;

my $variable : shared;
my @array    : shared;
my %hash     : shared;

share( $variable );
share( @array );
share( %hash );

lock( $variable );
cond_wait( $variable );
cond_wait( $variable, $lock_variable );
cond_timedwait( $variable, abs time );
cond_timedwait( $variable, abs time, $lock_variable );
cond_signal( $variable );
cond_broadcast( $variable );

DESCRIPTION

The "forks::shared" pragma allows a developer to use shared variables with threads (implemented with the "forks" pragma) without having to have a threaded perl, or to even run 5.8.0 or higher.

KNOWN PROBLEMS

These problems are known and will be fixed in the future:

test-suite exits in a weird way

Although there are no errors in the test-suite, the test harness thinks there is something wrong because of an unexpected exit() value. Not sure what to do about this yet. This appears to only occur on instances of perl built with native ithreads.

shared variable in push() on shared array bombs

For some reason, using a bare shared variable as a parameter in a push() on a shared array, bombs. This can be fixed by adding .'' to the shared variable.

push( @shared,$shared );    # bombs
push( @shared,$shared.'' ); # works

This could be a generic problem with tie() in Perl, judging from some very recent discussion on p5p.

ORIGINAL AUTHOR CREDITS

Arthur Bergman for Hook::Scope (from which I swiped the code to have locked variables automatically unlock upon leaving the scope they were locked in) and threads::shared (from which I swiped the code to create references from the parameter list passed to a subroutine).

CURRENT MAINTAINER

Eric Rybski <rybskej@yahoo.com>.

ORIGINAL AUTHOR

Elizabeth Mattijsen, <liz@dijkmat.nl>.

COPYRIGHT

Copyright (c) 2002-2004 Elizabeth Mattijsen <liz@dijkmat.nl>, 2005 Eric Rybski <rybskej@yahoo.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

forks, threads.