-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vm/cocurrency] Add simple spawn function test and test with/without …
…isolate groups This fixes also an issue when running without isolate groups. Issue #36097 Change-Id: I0fb64b3f2b755ccab4c36c6a0fafee7edff239cf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114204 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Martin Kustermann <kustermann@google.com>
- Loading branch information
1 parent
3c54aea
commit 68e805f
Showing
2 changed files
with
36 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
// VMOptions=--enable-isolate-groups | ||
// VMOptions=--no-enable-isolate-groups | ||
|
||
import 'dart:isolate'; | ||
import 'dart:async'; | ||
|
||
import 'package:expect/expect.dart'; | ||
|
||
void isolateEntry(args) { | ||
final SendPort sendPort = args; | ||
sendPort.send('hello world'); | ||
} | ||
|
||
main() async { | ||
final port = ReceivePort(); | ||
final exitPort = ReceivePort(); | ||
|
||
await Isolate.spawn(isolateEntry, port.sendPort, onExit: exitPort.sendPort); | ||
|
||
final messages = StreamIterator(port); | ||
Expect.isTrue(await messages.moveNext()); | ||
Expect.equals('hello world', messages.current); | ||
await messages.cancel(); | ||
|
||
final exit = StreamIterator(exitPort); | ||
Expect.isTrue(await exit.moveNext()); | ||
await exit.cancel(); | ||
} |