[libanyevent-rabbitmq-perl] 54/151: Support draining writes..
Damyan Ivanov
dmn at moszumanska.debian.org
Thu Jan 16 11:03:03 UTC 2014
This is an automated email from the git hooks/post-receive script.
dmn pushed a commit to annotated tag debian/1.12-1
in repository libanyevent-rabbitmq-perl.
commit 237ee32719419170895ce449c14fa62859adfd41
Author: Tomas Doran <bobtfish at bobtfish.net>
Date: Fri May 28 18:00:54 2010 +0100
Support draining writes..
If I want to use Net::RabbitFoot in a script that doesn't last for very long
then I need to be able to cause everything to get written before I shut
down. This allows me to do so with a timeout..
---
lib/AnyEvent/RabbitMQ.pm | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lib/AnyEvent/RabbitMQ.pm b/lib/AnyEvent/RabbitMQ.pm
index f633ff5..50f5633 100644
--- a/lib/AnyEvent/RabbitMQ.pm
+++ b/lib/AnyEvent/RabbitMQ.pm
@@ -80,6 +80,11 @@ sub connect {
$self->_disconnect();
$args{on_close}->($message);
},
+ on_drain => sub {
+ my ($handle) = @_;
+ $self->{drain_condvar}->send
+ if exists $self->{drain_condvar};
+ },
);
$self->_read_loop($args{on_close}, $args{on_read_failure});
$self->_start(%args,);
@@ -456,6 +461,18 @@ sub _check_open {
return 0;
}
+sub drain_writes {
+ my ($self, $timeout) = shift;
+ $self->{drain_condvar} = AnyEvent->condvar;
+ if ($timeout) {
+ $self->{drain_timer} = AnyEvent->timer( after => $timeout, sub {
+ $self->{drain_condvar}->croak("Timed out after $timeout");
+ });
+ }
+ $self->{drain_condvar}->recv;
+ delete $self->{drain_timer};
+}
+
sub DESTROY {
my $self = shift;
$self->close();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanyevent-rabbitmq-perl.git
More information about the Pkg-perl-cvs-commits
mailing list