mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 14:51:30 +00:00
35da19ac07
Change-Id: I0e97add738bc79314a210cf137525b7391467fc2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152595 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
50 lines
1.3 KiB
Dart
50 lines
1.3 KiB
Dart
// Copyright (c) 2012, 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.
|
|
|
|
library package_isolate_test;
|
|
|
|
import 'packages/shared.dart' as shared;
|
|
import 'dart:isolate';
|
|
import '../../../pkg/async_helper/lib/async_helper.dart';
|
|
import '../../../pkg/expect/lib/expect.dart';
|
|
|
|
expectResponse() {
|
|
asyncStart();
|
|
var receivePort = new ReceivePort();
|
|
receivePort.first.then((msg) {
|
|
Expect.equals('isolate', msg);
|
|
Expect.equals('main', shared.output);
|
|
asyncEnd();
|
|
});
|
|
return receivePort;
|
|
}
|
|
|
|
void main() {
|
|
{
|
|
var replyPort = expectResponse().sendPort;
|
|
shared.output = 'main';
|
|
Isolate.spawn(isolate_main, replyPort);
|
|
}
|
|
|
|
{
|
|
// Package in spawnUri() of sibling file.
|
|
var replyPort = expectResponse().sendPort;
|
|
shared.output = 'main';
|
|
Isolate.spawnUri(Uri.parse('sibling_isolate.dart'), [], replyPort);
|
|
}
|
|
|
|
{
|
|
// Package in spawnUri() of file in folder.
|
|
var replyPort = expectResponse().sendPort;
|
|
shared.output = 'main';
|
|
Isolate.spawnUri(
|
|
Uri.parse('test_folder/folder_isolate.dart'), [], replyPort);
|
|
}
|
|
}
|
|
|
|
void isolate_main(SendPort replyTo) {
|
|
shared.output = 'isolate';
|
|
replyTo.send(shared.output);
|
|
}
|