return bless $self, $class;
}
+sub DESTROY {
+ my $self = shift;
+
+ # If we have an error, don't flush - we might be flushing bad stuff. -RobK, 2008-06-26
+ die $@ if $@;
+
+ $self->_get_self->_engine->flush;
+}
+
# This initializer is called from the various TIE* methods. new() calls tie(),
# which allows for a single point of entry.
sub _init {
sub read_txn_slots {
my $self = shift;
- return $self->_load_header->read_txn_slots;
+ return $self->_load_header->read_txn_slots(@_);
}
sub write_txn_slots {
my $self = shift;
- my $num_bits = $self->txn_bitfield_len * 8;
- $self->storage->print_at( $self->trans_loc,
- pack( 'b'.$num_bits, join('', @_) ),
- );
+ return $self->_load_header->write_txn_slots(@_);
}
sub get_running_txn_ids {
sub get_txn_staleness_counter {
my $self = shift;
- my ($trans_id) = @_;
-
- # Hardcode staleness of 0 for the HEAD
- return 0 unless $trans_id;
-
- return unpack( $StP{$STALE_SIZE},
- $self->storage->read_at(
- $self->trans_loc + $self->txn_bitfield_len + $STALE_SIZE * ($trans_id - 1),
- $STALE_SIZE,
- )
- );
+ return $self->_load_header->get_txn_staleness_counter(@_);
}
sub inc_txn_staleness_counter {
my $self = shift;
- my ($trans_id) = @_;
-
- # Hardcode staleness of 0 for the HEAD
- return 0 unless $trans_id;
-
- $self->storage->print_at(
- $self->trans_loc + $self->txn_bitfield_len + $STALE_SIZE * ($trans_id - 1),
- pack( $StP{$STALE_SIZE}, $self->get_txn_staleness_counter( $trans_id ) + 1 ),
- );
+ return $self->_load_header->inc_txn_staleness_counter(@_);
}
sub get_entries {
return split '', unpack( 'b'.$num_bits, $self->read( $e->trans_loc, $bl ) );
}
+sub write_txn_slots {
+ my $self = shift;
+ my $e = $self->engine;
+ my $num_bits = $e->txn_bitfield_len * 8;
+ $self->write( $e->trans_loc,
+ pack( 'b'.$num_bits, join('', @_) ),
+ );
+}
+
+sub get_txn_staleness_counter {
+ my $self = shift;
+ my ($trans_id) = @_;
+
+ # Hardcode staleness of 0 for the HEAD
+ return 0 unless $trans_id;
+
+ my $e = $self->engine;
+ return unpack( $e->StP($DBM::Deep::Engine::STALE_SIZE),
+ $self->read(
+ $e->trans_loc + $e->txn_bitfield_len + $DBM::Deep::Engine::STALE_SIZE * ($trans_id - 1),
+ $DBM::Deep::Engine::STALE_SIZE,
+ )
+ );
+}
+
+sub inc_txn_staleness_counter {
+ my $self = shift;
+ my ($trans_id) = @_;
+
+ # Hardcode staleness of 0 for the HEAD
+ return 0 unless $trans_id;
+
+ my $e = $self->engine;
+ $self->write(
+ $e->trans_loc + $e->txn_bitfield_len + $DBM::Deep::Engine::STALE_SIZE * ($trans_id - 1),
+ pack( $e->StP($DBM::Deep::Engine::STALE_SIZE), $self->get_txn_staleness_counter( $trans_id ) + 1 ),
+ );
+}
+
1;
__END__
} qr/Storage of references of type 'GLOB' is not supported/,
'Storage of glob refs not supported';
- warn "\n1: " . $db->_engine->_dump_file;
$db->{scalar} = $x;
- warn "\n2: " . $db->_engine->_dump_file;
TODO: {
todo_skip "Refs to DBM::Deep objects aren't implemented yet", 2;
lives_ok {
is( ${$db->{selfref}}, $x, "A ref to a DBM::Deep object is ok" );
}
-
- warn $db->_engine->_dump_file;
}
{