Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update code to use new Supplier model.
  • Loading branch information
jnthn committed Nov 25, 2015
1 parent 0a8ab76 commit 0c4e50f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/core/IO/Notification.pm
Expand Up @@ -13,7 +13,7 @@ my class IO::Notification {
}

method watch-path(Str() $path, :$scheduler = $*SCHEDULER) {
my $s = Supply.new;
my $s = Supplier.new;
nqp::watchfile(
$scheduler.queue,
-> \path, \rename, \err {
Expand All @@ -26,6 +26,6 @@ my class IO::Notification {
}
},
$path, FileWatchCancellation);
$s
$s.Supply
}
}
1 change: 1 addition & 0 deletions src/core/List.pm
Expand Up @@ -4,6 +4,7 @@ my class X::TypeCheck::Splice { ... }
my class X::Cannot::Lazy { ... }
my class X::Cannot::Empty { ... }
my class Supply { ... }
my class Supplier { ... }

my sub combinations(\n, \k) {
return ((),) if k < 1;
Expand Down
10 changes: 5 additions & 5 deletions src/core/Proc/Async.pm
Expand Up @@ -63,23 +63,23 @@ my class Proc::Async {
if the-supply and type != value;

type = value;
the-supply //= Supply.new;
the-supply //= Supplier.new;
}

proto method stdout(|) { * }
multi method stdout(Proc::Async:D:) {
self!supply('stdout', $!stdout_supply, $!stdout_type, Chars);
self!supply('stdout', $!stdout_supply, $!stdout_type, Chars).Supply;
}
multi method stdout(Proc::Async:D: :$bin!) {
self!supply('stdout',$!stdout_supply,$!stdout_type,$bin ?? Bytes !! Chars);
self!supply('stdout',$!stdout_supply,$!stdout_type,$bin ?? Bytes !! Chars).Supply;
}

proto method stderr(|) { * }
multi method stderr(Proc::Async:D:) {
self!supply('stderr', $!stderr_supply, $!stderr_type, Chars);
self!supply('stderr', $!stderr_supply, $!stderr_type, Chars).Supply;
}
multi method stderr(Proc::Async:D: :$bin!) {
self!supply('stderr',$!stderr_supply,$!stderr_type,$bin ?? Bytes !! Chars);
self!supply('stderr',$!stderr_supply,$!stderr_type,$bin ?? Bytes !! Chars).Supply;
}

method !capture(\callbacks,\std,\type,\the-supply) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/Promise.pm
Expand Up @@ -204,7 +204,7 @@ my class Promise {
}

method Supply(Promise:D:) {
my $s = Supply.new;
my $s = Supplier.new;
self.then({
if self.status == Kept {
$s.emit(self.result);
Expand All @@ -214,7 +214,7 @@ my class Promise {
$s.quit(self.cause);
}
});
$s
$s.Supply
}

# experimental
Expand Down
4 changes: 2 additions & 2 deletions src/core/signals.pm
Expand Up @@ -55,12 +55,12 @@ sub signal(Signal $signal, *@signals, :$scheduler = $*SCHEDULER) {

my class SignalCancellation is repr('AsyncTask') { }
Supply.merge( @signals.map(-> $sig {
my $s = Supply.new;
my $s = Supplier.new;
nqp::signal($scheduler.queue,
-> $signum { $s.emit(@known_signals[$signum] // $signum) },
nqp::unbox_i(%sigmap{$sig}),
SignalCancellation);
$s
$s.Supply
}) );
}

Expand Down

0 comments on commit 0c4e50f

Please sign in to comment.