- print { $self->{out_c} } $obj, "\n" or fail($self, "write error: $!");
- my $rbuf = ''; # TODO: async + {chk_rbuf}
- chomp(my $line = my_readline($self->{in_c}, \$rbuf));
- my ($hex, $type, $size) = split(' ', $line);
+ die 'BUG: already in async check' if $self->{inflight_c};
+ $self->{inflight_c} = [];
+}
+
+sub check_async ($$$$) {
+ my ($self, $oid, $cb, $arg) = @_;
+ my $inflight_c = $self->{inflight_c} // check_async_begin($self);
+ while (scalar(@$inflight_c) >= MAX_INFLIGHT) {
+ check_async_step($self, $inflight_c);
+ }
+ print { $self->{out_c} } $oid, "\n" or $self->fail("write error: $!");
+ push(@$inflight_c, $oid, $cb, $arg);
+}
+
+sub _check_cb { # check_async callback
+ my ($hex, $type, $size, $result) = @_;
+ @$result = ($hex, $type, $size);
+}
+
+sub check {
+ my ($self, $oid) = @_;
+ my $result = [];
+ check_async($self, $oid, \&_check_cb, $result);
+ check_async_wait($self);
+ my ($hex, $type, $size) = @$result;