From 94096cab6cd5e00c8a36a4a2667bdb9acf43d01f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Jun 2020 10:03:38 +0000 Subject: ds: remove fields.pm usage 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. --- lib/PublicInbox/HTTPD/Async.pm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'lib/PublicInbox/HTTPD/Async.pm') 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 { -- cgit v1.2.3-24-ge0c7