[libanyevent-handle-udp-perl] 15/60: Add autoflush attribute, don't do it by default

Jonas Smedegaard js at alioth.debian.org
Mon Sep 30 10:05:38 UTC 2013


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository libanyevent-handle-udp-perl.

commit e741d7d6192d1004b66116ec7b16b61865f72386
Author: Leon Timmermans <fawaka at gmail.com>
Date:   Sun Feb 19 17:12:58 2012 +0100

    Add autoflush attribute, don't do it by default
---
 Changes                    |    1 +
 lib/AnyEvent/Handle/UDP.pm |   11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Changes b/Changes
index 9892a7a..1aa3c2a 100644
--- a/Changes
+++ b/Changes
@@ -4,6 +4,7 @@ Revision history for AnyEvent-Handle-UDP
           Make push_send optionally take a $cv, and only return one if called in non-void context
           Make resend logica actually work at all
           Made on_drain more consistent
+          Add autoflush attribute, but no longer autocork by default
 
 0.032     2012-02-14 02:13:50 Europe/Amsterdam
           Make push_send actually work
diff --git a/lib/AnyEvent/Handle/UDP.pm b/lib/AnyEvent/Handle/UDP.pm
index de49a96..b01bed5 100644
--- a/lib/AnyEvent/Handle/UDP.pm
+++ b/lib/AnyEvent/Handle/UDP.pm
@@ -90,6 +90,11 @@ has _full => (
 	predicate => '_has_full',
 );
 
+has autoflush => (
+	is => 'rw',
+	default => sub { 0 },
+);
+
 sub bind_to {
 	my ($self, $addr) = @_;
 	if (ref $addr) {
@@ -171,7 +176,7 @@ my %non_fatal = map { ( $_ => 1 ) } EAGAIN, EWOULDBLOCK, EINTR;
 sub push_send {
 	my ($self, $message, $to, $cv) = @_;
 	$cv ||= defined wantarray ? AnyEvent::CondVar->new : undef;
-	if (!$self->{writer}) {
+	if ($self->autoflush and ! @{ $self->{buffers} }) {
 		my $ret = $self->_send($message, $to, $cv);
 		$self->_push_writer($message, $to, $cv) if not defined $ret and $non_fatal{$! + 0};
 		$self->_drained if $ret;
@@ -259,6 +264,10 @@ The callback for when an error occurs. It takes three arguments: the handle, a b
 
 This sets the callback that is called when the send buffer becomes empty. The callback takes the handle as its only argument.
 
+=attr autoflush
+
+Always attempt to send data to the operating system immediately, without waiting for the loop to indicate the filehandle is write-ready.
+
 =attr receive_size
 
 The buffer size for the receiving in bytes. It defaults to 1500, which is slightly more than the MTA on ethernet.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libanyevent-handle-udp-perl.git



More information about the Pkg-perl-cvs-commits mailing list