summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util/Tools.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/Util/Tools.pm')
-rw-r--r--lib/VNDB/Util/Tools.pm17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/VNDB/Util/Tools.pm b/lib/VNDB/Util/Tools.pm
index caa66ef4..9579e2c9 100644
--- a/lib/VNDB/Util/Tools.pm
+++ b/lib/VNDB/Util/Tools.pm
@@ -151,12 +151,19 @@ sub AddDefaultStuff {
}
+# commands aren't actually sent until the function is called without cmd parameter
sub RunCmd { # cmd
- my $s = tie my %s, 'Tie::ShareLite', @VNDB::SHMOPTS;
- $s->lock(LOCK_EX);
- my @q = ( ($s{queue} ? @{$s{queue}} : ()), $_[1] );
- $s{queue} = \@q;
- $s->unlock();
+ my($self, $c) = @_;
+ if($c) {
+ push @{$self->{cmds}}, $c;
+ } else {
+ my $s = tie my %s, 'Tie::ShareLite', @VNDB::SHMOPTS;
+ $s->lock(LOCK_EX);
+ my @q = ( ($s{queue} ? @{$s{queue}} : ()), @{$self->{cmds}} );
+ $s{queue} = \@q;
+ $s->unlock();
+ $self->{cmds} = [];
+ }
}