X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBM%2FDeep%2FArray.pm;h=b4a4636cf8bdef9ce4807e9453f773067528212a;hb=641aa32d2d78eb7084801c7b9aa91f962c8af75f;hp=73babc58ccc7553f4d4e21ad52391aec8afbc117;hpb=065b45be4e413444714f0b35aa9653e10753118b;p=dbsrgits%2FDBM-Deep.git diff --git a/lib/DBM/Deep/Array.pm b/lib/DBM/Deep/Array.pm index 73babc5..b4a4636 100644 --- a/lib/DBM/Deep/Array.pm +++ b/lib/DBM/Deep/Array.pm @@ -33,7 +33,7 @@ sub FETCH { my $self = shift->_get_self; my ($key) = @_; - $self->lock( $self->LOCK_SH ); + $self->lock_shared; if ( !defined $key ) { $self->unlock; @@ -64,7 +64,7 @@ sub STORE { my $self = shift->_get_self; my ($key, $value) = @_; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; my $size; my $idx_is_numeric; @@ -105,7 +105,7 @@ sub EXISTS { my $self = shift->_get_self; my ($key) = @_; - $self->lock( $self->LOCK_SH ); + $self->lock_shared; if ( !defined $key ) { $self->unlock; @@ -137,7 +137,7 @@ sub DELETE { my ($key) = @_; warn "ARRAY::DELETE($self,$key)\n" if DBM::Deep::DEBUG; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; my $size = $self->FETCHSIZE; if ( !defined $key ) { @@ -169,20 +169,20 @@ sub DELETE { return $rv; } -# Now that we have a real Reference sector, we should store arrayzize there. However, -# arraysize needs to be transactionally-aware, so a simple location to store it isn't -# going to work. +# Now that we have a real Reference sector, we should store arrayzize there. +# However, arraysize needs to be transactionally-aware, so a simple location to +# store it isn't going to work. sub FETCHSIZE { my $self = shift->_get_self; - $self->lock( $self->LOCK_SH ); + $self->lock_shared; - my $SAVE_FILTER = $self->_storage->{filter_fetch_value}; - $self->_storage->{filter_fetch_value} = undef; + my $SAVE_FILTER = $self->_engine->storage->{filter_fetch_value}; + $self->_engine->storage->{filter_fetch_value} = undef; my $size = $self->FETCH('length') || 0; - $self->_storage->{filter_fetch_value} = $SAVE_FILTER; + $self->_engine->storage->{filter_fetch_value} = $SAVE_FILTER; $self->unlock; @@ -193,14 +193,14 @@ sub STORESIZE { my $self = shift->_get_self; my ($new_length) = @_; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; - my $SAVE_FILTER = $self->_storage->{filter_store_value}; - $self->_storage->{filter_store_value} = undef; + my $SAVE_FILTER = $self->_engine->storage->{filter_store_value}; + $self->_engine->storage->{filter_store_value} = undef; my $result = $self->STORE('length', $new_length, 'length'); - $self->_storage->{filter_store_value} = $SAVE_FILTER; + $self->_engine->storage->{filter_store_value} = $SAVE_FILTER; $self->unlock; @@ -210,7 +210,7 @@ sub STORESIZE { sub POP { my $self = shift->_get_self; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; my $length = $self->FETCHSIZE(); @@ -231,7 +231,7 @@ sub POP { sub PUSH { my $self = shift->_get_self; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; my $length = $self->FETCHSIZE(); @@ -258,7 +258,7 @@ sub SHIFT { my $self = shift->_get_self; warn "SHIFT($self)\n" if DBM::Deep::DEBUG; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; my $length = $self->FETCHSIZE(); @@ -287,7 +287,7 @@ sub UNSHIFT { my $self = shift->_get_self; my @new_elements = @_; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; my $length = $self->FETCHSIZE(); my $new_size = scalar @new_elements; @@ -312,7 +312,7 @@ sub UNSHIFT { sub SPLICE { my $self = shift->_get_self; - $self->lock( $self->LOCK_EX ); + $self->lock_exclusive; my $length = $self->FETCHSIZE(); @@ -376,12 +376,9 @@ sub SPLICE { # We don't need to populate it, yet. # It will be useful, though, when we split out HASH and ARRAY -sub EXTEND { - ## - # Perl will call EXTEND() when the array is likely to grow. - # We don't care, but include it because it gets called at times. - ## -} +# Perl will call EXTEND() when the array is likely to grow. +# We don't care, but include it because it gets called at times. +sub EXTEND {} sub _copy_node { my $self = shift; @@ -395,14 +392,11 @@ sub _copy_node { return 1; } -## -# Public method aliases -## -sub length { (shift)->FETCHSIZE(@_) } -sub pop { (shift)->POP(@_) } -sub push { (shift)->PUSH(@_) } -sub unshift { (shift)->UNSHIFT(@_) } -sub splice { (shift)->SPLICE(@_) } +sub length { (shift)->FETCHSIZE(@_) } +sub pop { (shift)->POP(@_) } +sub push { (shift)->PUSH(@_) } +sub unshift { (shift)->UNSHIFT(@_) } +sub splice { (shift)->SPLICE(@_) } # This must be last otherwise we have to qualify all other calls to shift # as calls to CORE::shift