File Coverage

blib/lib/DBM/Deep/Storage.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 5 5 100.0
total 26 26 100.0


line stmt bran cond sub pod time code
1             package DBM::Deep::Storage;
2              
3 51     51   2113 use 5.008_004;
  51         180  
4              
5 51     51   273 use strict;
  51         110  
  51         1292  
6 51     51   266 use warnings FATAL => 'all';
  51         119  
  51         6325  
7              
8             =head1 NAME
9              
10             DBM::Deep::Storage - abstract base class for storage
11              
12             =head2 flush()
13              
14             This flushes the filehandle. This takes no parameters and returns nothing.
15              
16             =cut
17              
18 2     2 1 15 sub flush { die "flush must be implemented in a child class" }
19              
20             =head2 is_writable()
21              
22             This takes no parameters. It returns a boolean saying if this filehandle is
23             writable.
24              
25             Taken from L.
26              
27             =cut
28              
29 1     1 1 9 sub is_writable { die "is_writable must be implemented in a child class" }
30              
31             =head1 LOCKING
32              
33             This is where the actual locking of the storage medium is performed.
34             Nested locking is supported.
35              
36             B: It is unclear what will happen if a read lock is taken, then
37             a write lock is taken as a nested lock, then the write lock is released.
38              
39             Currently, the only locking method supported is flock(1). This is a
40             whole-file lock. In the future, more granular locking may be supported.
41             The API for that is unclear right now.
42              
43             The following methods manage the locking status. In all cases, they take
44             a L object and returns nothing.
45              
46             =over 4
47              
48             =item * lock_exclusive( $obj )
49              
50             Take a lock usable for writing.
51              
52             =item * lock_shared( $obj )
53              
54             Take a lock usable for reading.
55              
56             =item * unlock( $obj )
57              
58             Releases the last lock taken. If this is the outermost lock, then the
59             object is actually unlocked.
60              
61             =back
62              
63             =cut
64              
65 1     1 1 10 sub lock_exclusive { die "lock_exclusive must be implemented in a child class" }
66 1     1 1 8 sub lock_shared { die "lock_shared must be implemented in a child class" }
67 4     4 1 33 sub unlock { die "unlock must be implemented in a child class" }
68              
69             1;
70             __END__