diff --git a/lib/IO/Select.pm b/lib/IO/Select.pm index 43de3d2..08da870 100644 --- a/lib/IO/Select.pm +++ b/lib/IO/Select.pm @@ -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)); } }