diff --git a/src/core/JVM/IOAsyncFile.pm6 b/src/core/JVM/IOAsyncFile.pm6 deleted file mode 100644 index ee8b1272c08..00000000000 --- a/src/core/JVM/IOAsyncFile.pm6 +++ /dev/null @@ -1,78 +0,0 @@ -# Very basic asynchronous I/O support for files. Work in progress. Things that -# would nomally return something scalar-ish produce a Promise. Things that -# would normally return a (lazy) list produce a Channel. -my class IO::Async::File { - has $!PIO; - has $.chomp = Bool::True; - has $.path; - - proto method open(|) {*} - multi method open($path? is copy, :$r, :$w, :$a, :$bin, :$chomp = Bool::True, - :enc(:$encoding) = 'utf8') { - $path //= $!path; - my $mode = $w ?? 'w' !! ($a ?? 'wa' !! 'r' ); - nqp::bindattr(self, IO::Async::File, '$!PIO', - nqp::openasync(nqp::unbox_s($path.Str), nqp::unbox_s($mode)) - ); - $!path = $path; - $!chomp = $chomp; - nqp::setencoding($!PIO, Rakudo::Internals.NORMALIZE_ENCODING($encoding)) - unless $bin; - self; - } - - method close() { - nqp::closefh($!PIO); - Bool::True; - } - - method opened() { - nqp::p6bool(nqp::istrue($!PIO)); - } - - method slurp(IO::Async::File:D: :$bin, :enc($encoding)) { - self.open(:r, :$bin) unless self.opened; - self.encoding($encoding) if $encoding.defined; - - if $bin { - die "Asynchronous binary file reading NYI" - } - else { - my $p = Promise.new; - nqp::slurpasync($!PIO, Str, - -> $str { $p.keep($str); self.close(); }, - -> $msg { $p.break($msg); try self.close(); }); - $p - } - } - - method spurt(IO::Async::File:D: $data, :$bin, :enc($encoding)) { - self.open(:w, :$bin) unless self.opened; - self.encoding($encoding) if $encoding.defined; - - if $bin { - die "Asynchronous binary file writing NYI" - } - else { - my $p = Promise.new; - nqp::spurtasync($!PIO, Str, $data, - -> { $p.keep(1); self.close(); }, - -> $msg { $p.break($msg); try self.close(); }); - $p - } - } - - method lines(:enc($encoding)) { - self.open(:r) unless self.opened; - self.encoding($encoding) if $encoding.defined; - - my $c := Channel.new; - nqp::linesasync($!PIO, Str, $.chomp ?? 1 !! 0, - nqp::getattr($c, Channel, '$!queue'), - -> { $c.close(); self.close() }, - -> $msg { $c.fail($msg); try self.close(); }); - $c - } -} - -# vim: ft=perl6 expandtab sw=4 diff --git a/src/core/JVM/KeyReducer.pm6 b/src/core/JVM/KeyReducer.pm6 deleted file mode 100644 index c8651289216..00000000000 --- a/src/core/JVM/KeyReducer.pm6 +++ /dev/null @@ -1,90 +0,0 @@ -# A KeyReducer provides a thread-safe way to compose a hash from multiple -# sources. -my class X::KeyReducer::ResultObtained is Exception { - method message() { "Cannot contribute to a KeyReducer after the result has been obtained" } -} -my class KeyReducer { - has $!initializer; - has $!reducer; - has %!result; - has Mu $!lock; - has $!exception; - has $!obtained; - - method new($initializer, $reducer) { - self.bless(:$initializer, :$reducer) - } - - my Mu $interop; - my Mu $ReentrantLock; - submethod BUILD(:$!initializer, :$!reducer --> Nil) { - unless nqp::isconcrete($interop) { - $interop := nqp::jvmbootinterop(); - $ReentrantLock := $interop.typeForName('java.util.concurrent.locks.ReentrantLock'); - } - $!lock := $ReentrantLock.'constructor/new/()V'(); - $!obtained = False; - } - - proto method contribute(|) {*} - multi method contribute(KeyReducer:D: %h) { - $!lock.lock(); - if $!exception { - $!lock.unlock(); - return False; - } - if $!obtained { - $!lock.unlock(); - X::KeyReducer::ResultObtained.new.throw - } - try { - for %h.kv -> $k, $v { - %!result{$k} = %!result.exists($k) - ?? $!reducer(%!result{$k}, $v) - !! $!initializer($v) - } - CATCH { default { $!exception := $_ } } - } - $!lock.unlock(); - True - } - multi method contribute(KeyReducer:D: Pair $p) { - $!lock.lock(); - if $!exception { - $!lock.unlock(); - return False; - } - if $!obtained { - $!lock.unlock(); - X::KeyReducer::ResultObtained.new.throw - } - try { - %!result{$p.key} = %!result.exists($p.key) - ?? $!reducer(%!result{$p.key}, $p.value) - !! $!initializer($p.value); - CATCH { default { $!exception := $_ } } - } - $!lock.unlock(); - True - } - - method snapshot(KeyReducer:D:) { - $!lock.lock(); - if $!exception { - $!lock.unlock(); - $!exception.throw; - } - my %snapshot = %!result; - $!lock.unlock(); - %snapshot - } - - method result(KeyReducer:D:) { - $!lock.lock(); - $!obtained = True; - $!lock.unlock(); - $!exception ?? $!exception.throw !! %!result - } -} - -# vim: ft=perl6 expandtab sw=4 diff --git a/tools/build/jvm_core_sources b/tools/build/jvm_core_sources index 48d0904eb69..2ea72c745e9 100644 --- a/tools/build/jvm_core_sources +++ b/tools/build/jvm_core_sources @@ -165,8 +165,6 @@ src/core/CurrentThreadScheduler.pm6 src/core/Promise.pm6 src/core/Channel.pm6 src/core/Supply.pm6 -src/core/JVM/KeyReducer.pm6 -src/core/JVM/IOAsyncFile.pm6 src/core/asyncops.pm6 src/core/atomicops.pm6 src/core/IO/Socket.pm6