Implement global advisory lock
This commit is contained in:
parent
9db2b208eb
commit
22ca2ec61e
14 changed files with 288 additions and 92 deletions
|
@ -9,6 +9,7 @@ use Carp ();
|
|||
use List::Util ();
|
||||
use RevBank::Global;
|
||||
use RevBank::Users;
|
||||
use RevBank::FileIO;
|
||||
use RevBank::Cart::Entry;
|
||||
|
||||
sub new($class) {
|
||||
|
@ -82,16 +83,19 @@ sub checkout($self, $user) {
|
|||
}
|
||||
|
||||
my $transaction_id = time() - 1300000000;
|
||||
RevBank::Plugins::call_hooks("checkout", $self, $user, $transaction_id);
|
||||
|
||||
for my $account (reverse sort keys %deltas) {
|
||||
# The reverse sort is a lazy way to make the "-" accounts come last,
|
||||
# which looks nicer with the "cash" plugin.
|
||||
RevBank::Users::update($account, $deltas{$account}, $transaction_id)
|
||||
if $deltas{$account} != 0;
|
||||
}
|
||||
RevBank::FileIO::with_lock {
|
||||
RevBank::Plugins::call_hooks("checkout", $self, $user, $transaction_id);
|
||||
|
||||
RevBank::Plugins::call_hooks("checkout_done", $self, $user, $transaction_id);
|
||||
for my $account (reverse sort keys %deltas) {
|
||||
# The reverse sort is a lazy way to make the "-" accounts come last,
|
||||
# which looks nicer with the "cash" plugin.
|
||||
RevBank::Users::update($account, $deltas{$account}, $transaction_id)
|
||||
if $deltas{$account} != 0;
|
||||
}
|
||||
|
||||
RevBank::Plugins::call_hooks("checkout_done", $self, $user, $transaction_id);
|
||||
};
|
||||
|
||||
$self->empty;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue