forks::BerkeleyDB::shared::handle - class for tie-ing handles to threads with forks


forks-BerkeleyDB documentation Contained in the forks-BerkeleyDB distribution.

Index


Code Index:

NAME

Top

forks::BerkeleyDB::shared::handle - class for tie-ing handles to threads with forks

DESCRIPTION

Top

Helper class for forks::BerkeleyDB::shared. See documentation there.

AUTHOR

Top

Eric Rybski <rybskej@yahoo.com>.

COPYRIGHT

Top

SEE ALSO

Top

forks::BerkeleyDB::shared, forks::shared.


forks-BerkeleyDB documentation Contained in the forks-BerkeleyDB distribution.

package forks::BerkeleyDB::shared::handle;

# Make sure we have version info for this module
# Make sure we do everything by the book from now on

$VERSION = 0.060;
use strict;
use warnings;

our $AUTOLOAD;

# Need to implement all subs except TIEHANDLE with the command:
#	my @result = _command( '_tied',$self->{'ordinal'},$sub,@_ );
# where $sub is a threads::shared:: qualified command.  AUTOLOAD might work.
#hey! I don't even have to do this...it's already handled by threads::shared

*_command = \&threads::_command;

#---------------------------------------------------------------------------
sub new {
	my $type = shift;
	my $class = ref($type) || $type;
	my $self = {};
	return bless($self, $class);
}

# standard Perl features
#	TIEHANDLE
#	WRITE, PRINT, PRINTF
#	READ, READLINE, GETC
#	CLOSE
#	BINMODE, OPEN, EOF, FILENO, SEEK, TELL
#	UNTIE, DESTROY

#---------------------------------------------------------------------------
*TIEHANDLE = *TIEHANDLE = \&new;

#---------------------------------------------------------------------------
sub AUTOLOAD {	#use forks::shared default method for everything!
    my $self = shift;
    (my $sub = $AUTOLOAD) =~ s#^.*::#$self->{'module'}::#;
    my @result = _command( '_tied',$self->{'ordinal'},$sub,@_ );
    wantarray ? @result : $result[0];
}

#---------------------------------------------------------------------------
1;

__END__