Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove a layer of indirection, and lots of code related to it

  • Loading branch information...
commit a8b3772fd91d8e40c3ac6bc4966c7f05ee474561 1 parent dfbf14d
Moritz Lenz moritz authored
Showing with 3 additions and 22 deletions.
  1. +3 −22 lib/IO/Select.pm
25 lib/IO/Select.pm
View
@@ -2,15 +2,12 @@ pir::loadlib__Ps('select');
class IO::Select {
has $!pmc;
- has $!iter = 'FH1';
- has %!handles;
submethod BUILD {
$!pmc := pir::new__Ps('Select');
}
method add($handle) {
- %!handles{$!iter} = $handle;
my Mu $fh := nqp::getattr(
pir::perl6_decontainerize__PP($handle), $handle.WHAT, '$!PIO'
);
@@ -24,30 +21,14 @@ class IO::Select {
# XXX No idea how to obtain an actual fd or any other unique
# identifier, so I'll just assign consequent letters of alphabet
# to each one
- $!pmc.update($fh, nqp::unbox_s($!iter), nqp::unbox_i($mode));
- $!iter.=succ;
+ $!pmc.update($fh, $handle, nqp::unbox_i($mode));
}
method can_read($timeout as Num) {
- my @parcel := $!pmc.can_read(nqp::unbox_n($timeout));
- return self.get_handles(@parcel);
+ $!pmc.can_read(nqp::unbox_n($timeout));
}
method can_write($timeout as Num) {
- my @parcel := $!pmc.can_write(nqp::unbox_n($timeout));
- return self.get_handles(@parcel);
- }
-
- method get_handles(@parcel) {
- my Mu $ids := nqp::getattr(
- @parcel, Parcel, '$!storage'
- );
- my int $elems = pir::elements($ids);
- my @res;
- loop (my int $i = 0; $i < $elems; $i = $i + 1) {
- my Str $item := nqp::p6box_s(nqp::atpos($ids, $i));
- @res.push: %!handles{$item};
- }
- return @res;
+ $!pmc.can_write(nqp::unbox_n($timeout));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.