NAME

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

SYNOPSIS

use forks;
use forks::shared;

my $variable : shared; # attributes do not work yet

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

lock( $variable );
cond_wait( $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:

:shared attribute

The :shared attribute on variables does not work yet. Use the threads::share function instead.

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.

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.

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).

AUTHOR

Elizabeth Mattijsen, <liz@dijkmat.nl>.

Please report bugs to <perlbugs@dijkmat.nl>.

COPYRIGHT

Copyright (c) 2002 Elizabeth Mattijsen <liz@dijkmat.nl>. 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.