| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package KiokuDB::LiveObjects::TXNScope; |
|
4
|
22
|
|
|
22
|
|
105
|
use Moose; |
|
|
22
|
|
|
|
|
30
|
|
|
|
22
|
|
|
|
|
162
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
22
|
|
|
22
|
|
110967
|
use Scalar::Util qw(weaken); |
|
|
22
|
|
|
|
|
45
|
|
|
|
22
|
|
|
|
|
1339
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
22
|
|
|
22
|
|
117
|
use namespace::clean -except => 'meta'; |
|
|
22
|
|
|
|
|
35
|
|
|
|
22
|
|
|
|
|
208
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has entries => ( |
|
11
|
|
|
|
|
|
|
isa => "ArrayRef", |
|
12
|
|
|
|
|
|
|
is => "ro", |
|
13
|
|
|
|
|
|
|
default => sub { [] }, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has live_objects => ( |
|
17
|
|
|
|
|
|
|
isa => "KiokuDB::LiveObjects", |
|
18
|
|
|
|
|
|
|
is => "ro", |
|
19
|
|
|
|
|
|
|
required => 1, |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has parent => ( |
|
23
|
|
|
|
|
|
|
isa => __PACKAGE__, |
|
24
|
|
|
|
|
|
|
is => "ro", |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub push { |
|
28
|
4313
|
|
|
4313
|
0
|
7578
|
my ( $self, @entries ) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
4313
|
|
|
|
|
120848
|
my $e = $self->entries; |
|
31
|
|
|
|
|
|
|
|
|
32
|
4313
|
|
|
|
|
7505
|
foreach my $entry ( @entries ) { |
|
33
|
4313
|
|
|
|
|
6782
|
push @$e, $entry; |
|
34
|
4313
|
|
|
|
|
34480
|
weaken($e->[-1]); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub rollback { |
|
39
|
140
|
|
|
140
|
1
|
232
|
my $self = shift; |
|
40
|
140
|
|
|
|
|
4595
|
$self->live_objects->rollback_entries(grep { defined } splice @{ $self->entries }); |
|
|
480
|
|
|
|
|
1075
|
|
|
|
140
|
|
|
|
|
4014
|
|
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub DEMOLISH { |
|
44
|
1143
|
|
|
1143
|
0
|
2294
|
my $self = shift; |
|
45
|
|
|
|
|
|
|
|
|
46
|
1143
|
50
|
|
|
|
34048
|
if ( my $l = $self->live_objects ) { |
|
47
|
1143
|
100
|
|
|
|
33009
|
if ( my $parent = $self->parent ) { |
|
48
|
68
|
|
|
|
|
2301
|
$l->_set_txn_scope($parent); |
|
49
|
|
|
|
|
|
|
} else { |
|
50
|
1075
|
|
|
|
|
33980
|
$l->_clear_txn_scope(); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__PACKAGE__ |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
KiokuDB::LiveObjects::TXNScope - Transaction scope. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$txn_scope = $live_objects->new_txn; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$txn_scope->update_entries(@updated); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
$txn_scope->rollback; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This is an auxillary class used by transaction scoping to roll back entrries |
|
78
|
|
|
|
|
|
|
updated during a transaction when it is aborted. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This is used internally in L<KiokuDB/txn_do> and should not need to be used |
|
81
|
|
|
|
|
|
|
directly. |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over 4 |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item entries |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
An ordered log of updated entries. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=back |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 METHODS |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item update_entries |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Called by L<KiokuDB::LiveObjects/update_entries>. Adds entries to C<entries>. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item rollback |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Calls C<KiokuDB::LiveObjects/rollback_entries> with all the recorded entries. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|