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 );
bless( $variable, class name );
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.
EXPORT
share
, cond_wait
, cond_timedwait
, cond_signal
, cond_broadcast
, is_shared
, bless
See "EXPORT" in threads::shared for more information.
OBJECTS
forks::shared exports a versio of bless() that works on shared objects, such that blessings propagate across threads. See threads::shared for usage information and the forks test suite for additional examples.
NOTES
As of threads::shared 1.01, the splice function has not yet been implememted for arrays; however, forks::shared fully supports splice on shared arrays.
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 sometimes thinks there is something wrong because of an unexpected exit() value. This is an issue with Test::More's END block, which wasn't designed to co-exist with a threads environment and forked processes. Hopefully, that module will be patched in the future, but for now, the warnings are harmless and may be safely ignored.
-
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
-
For some of the XS code used for forks::shared exported bless function.
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) 2005-2006 Eric Rybski <rybskej@yahoo.com>, 2002-2004 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.