Skip to content

Commit

Permalink
Fixing a race in pipeOn and tidying pipeOn tests (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpeach-sag committed Sep 25, 2018
1 parent 5560197 commit 90d3861
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/rx/operators/internals/PipeOn.mon
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ event PipeOnOnConnection {

if not spawned and not spawning {
spawning := true;
monitor.subscribe(downstreamChannel); // Need to subscribe before spawning otherwise the spawned context could send Spawned() before we have subscribed
spawnToContext(downstreamChannel);
}
if spawning {
Expand Down Expand Up @@ -95,7 +96,7 @@ event PipeOnOnConnection {
ifpresent upstream {
upstream.dispose();
}
upstream := new IDisposable;
upstream := new optional<IDisposable>;

if spawned {
send Dispose(downstreamChannel) to downstreamChannel;
Expand Down
10 changes: 0 additions & 10 deletions test/tests/Operators/PipeOn/Async/Input/test.mon
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ monitor TestObservable {
.subscribeOn(Subscriber.create().onNext(checkContextNext).onComplete(checkContextComplete), testContext);
}

action generator(IResolver resolver) {
checkContext();
on all wait(0.1) and not wait(0.5) {
resolver.next("Value");
}
on wait(0.5) {
resolver.complete();
}
}

action checkContextNext(any value) {
checkContext();
}
Expand Down
12 changes: 1 addition & 11 deletions test/tests/Operators/PipeOn/Sync/Input/test.mon
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,7 @@ monitor TestObservable {
.do(ExpectValues.create([<any>0.0, 1.0, 2.0, 3.0], checkContext, test.fail))
.subscribeOn(Subscriber.create().onNext(checkContextNext).onComplete(checkContextComplete), testContext);
}

action generator(IResolver resolver) {
checkContext();
on all wait(0.1) and not wait(0.5) {
resolver.next("Value");
}
on wait(0.5) {
resolver.complete();
}
}


action checkContextNext(any value) {
checkContext();
}
Expand Down

0 comments on commit 90d3861

Please sign in to comment.