about summary refs log tree commit homepage
path: root/lib/PublicInbox/HTTPD/Async.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-06-27 10:03:38 +0000
committerEric Wong <e@yhbt.net>2020-06-28 22:27:15 +0000
commit94096cab6cd5e00c8a36a4a2667bdb9acf43d01f (patch)
tree791b61b5e115e6ca0835a4f55445795b0d766dc1 /lib/PublicInbox/HTTPD/Async.pm
parent58c0333adbdd9f5f82309cb6eef3c379f0ff064e (diff)
downloadpublic-inbox-94096cab6cd5e00c8a36a4a2667bdb9acf43d01f.tar.gz
Since the removal of pseudo-hash support in Perl 5.10, the
"fields" module no longer provides the space or speed benefits
it did in 5.8.  It also does not allow for compile-time checks,
only run-time checks.

To me, the extra developer overhead in maintaining "use fields"
args has become a hassle.  None of our non-DS-related code uses
fields.pm, nor do any of our current dependencies.  In fact,
Danga::Socket (which DS was originally forked from) and its
subclasses are the only fields.pm users I've ever encountered in
the wild.  Removing fields may make our code more approachable
to other Perl hackers.

So stop using fields.pm and locked hashes, but continue to
document what fields do for non-trivial classes.
Diffstat (limited to 'lib/PublicInbox/HTTPD/Async.pm')
-rw-r--r--lib/PublicInbox/HTTPD/Async.pm22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/PublicInbox/HTTPD/Async.pm b/lib/PublicInbox/HTTPD/Async.pm
index 35075d34..87a6a5f9 100644
--- a/lib/PublicInbox/HTTPD/Async.pm
+++ b/lib/PublicInbox/HTTPD/Async.pm
@@ -6,11 +6,16 @@
 # The name of this key is not even stable!
 # Currently intended for use with read-only pipes with expensive
 # processes such as git-http-backend(1), cgit(1)
+#
+# fields:
+# http: PublicInbox::HTTP ref
+# fh: PublicInbox::HTTP::{Identity,Chunked} ref (can ->write + ->close)
+# cb: initial read callback
+# arg: arg for {cb}
+# end_obj: CODE or object which responds to ->event_step when ->close is called
 package PublicInbox::HTTPD::Async;
 use strict;
-use warnings;
-use base qw(PublicInbox::DS);
-use fields qw(http fh cb arg end_obj);
+use parent qw(PublicInbox::DS);
 use Errno qw(EAGAIN);
 use PublicInbox::Syscall qw(EPOLLIN EPOLLET);
 
@@ -27,14 +32,13 @@ sub new {
                 die '$end_obj unsupported w/o $io' if $end_obj;
                 return;
         }
-
-        my $self = fields::new($class);
+        my $self = bless {
+                cb => $cb, # initial read callback
+                arg => $arg, # arg for $cb
+                end_obj => $end_obj, # like END{}, can ->event_step
+        }, $class;
         IO::Handle::blocking($io, 0);
         $self->SUPER::new($io, EPOLLIN | EPOLLET);
-        $self->{cb} = $cb; # initial read callback
-        $self->{arg} = $arg; # arg for $cb
-        $self->{end_obj} = $end_obj; # like END{}, can ->event_step
-        $self;
 }
 
 sub event_step {