| 1 | package forks::BerkeleyDB::shared::handle; | ||
| 2 | |||
| 3 | # Make sure we have version info for this module | ||
| 4 | # Make sure we do everything by the book from now on | ||
| 5 | |||
| 6 | $VERSION = 0.060; | ||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | our $AUTOLOAD; | ||
| 11 | |||
| 12 | # Need to implement all subs except TIEHANDLE with the command: | ||
| 13 | # my @result = _command( '_tied',$self->{'ordinal'},$sub,@_ ); | ||
| 14 | # where $sub is a threads::shared:: qualified command. AUTOLOAD might work. | ||
| 15 | #hey! I don't even have to do this...it's already handled by threads::shared | ||
| 16 | |||
| 17 | *_command = \&threads::_command; | ||
| 18 | |||
| 19 | #--------------------------------------------------------------------------- | ||
| 20 | sub new { | ||
| 21 | my $type = shift; | ||
| 22 | my $class = ref($type) || $type; | ||
| 23 | my $self = {}; | ||
| 24 | return bless($self, $class); | ||
| 25 | } | ||
| 26 | |||
| 27 | # standard Perl features | ||
| 28 | # TIEHANDLE | ||
| 29 | # WRITE, PRINT, PRINTF | ||
| 30 | # READ, READLINE, GETC | ||
| 31 | # CLOSE | ||
| 32 | # BINMODE, OPEN, EOF, FILENO, SEEK, TELL | ||
| 33 | # UNTIE, DESTROY | ||
| 34 | |||
| 35 | #--------------------------------------------------------------------------- | ||
| 36 | *TIEHANDLE = *TIEHANDLE = \&new; | ||
| 37 | |||
| 38 | #--------------------------------------------------------------------------- | ||
| 39 | sub AUTOLOAD { #use forks::shared default method for everything! | ||
| 40 | my $self = shift; | ||
| 41 | (my $sub = $AUTOLOAD) =~ s#^.*::#$self->{'module'}::#; | ||
| 42 | my @result = _command( '_tied',$self->{'ordinal'},$sub,@_ ); | ||
| 43 | wantarray ? @result : $result[0]; | ||
| 44 | } | ||
| 45 | |||
| 46 | #--------------------------------------------------------------------------- | ||
| 47 | 1; | ||
| 48 | |||
| 49 | __END__ |