Skip to content

Commit 68e805f

Browse files
mkustermanncommit-bot@chromium.org
authored and
commit-bot@chromium.org
committed
[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>
1 parent 3c54aea commit 68e805f

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

runtime/bin/main.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,11 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
662662
}
663663

664664
if (flags->copy_parent_code && callback_data) {
665-
IsolateGroupData* parent_isolate_data =
666-
reinterpret_cast<IsolateGroupData*>(callback_data);
667-
parent_kernel_buffer = parent_isolate_data->kernel_buffer();
665+
auto parent_isolate_group_data =
666+
reinterpret_cast<IsolateData*>(callback_data)->isolate_group_data();
667+
parent_kernel_buffer = parent_isolate_group_data->kernel_buffer();
668668
kernel_buffer = parent_kernel_buffer.get();
669-
kernel_buffer_size = parent_isolate_data->kernel_buffer_size();
669+
kernel_buffer_size = parent_isolate_group_data->kernel_buffer_size();
670670
}
671671

672672
if (kernel_buffer == NULL && !isolate_run_app_snapshot) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// VMOptions=--enable-isolate-groups
6+
// VMOptions=--no-enable-isolate-groups
7+
8+
import 'dart:isolate';
9+
import 'dart:async';
10+
11+
import 'package:expect/expect.dart';
12+
13+
void isolateEntry(args) {
14+
final SendPort sendPort = args;
15+
sendPort.send('hello world');
16+
}
17+
18+
main() async {
19+
final port = ReceivePort();
20+
final exitPort = ReceivePort();
21+
22+
await Isolate.spawn(isolateEntry, port.sendPort, onExit: exitPort.sendPort);
23+
24+
final messages = StreamIterator(port);
25+
Expect.isTrue(await messages.moveNext());
26+
Expect.equals('hello world', messages.current);
27+
await messages.cancel();
28+
29+
final exit = StreamIterator(exitPort);
30+
Expect.isTrue(await exit.moveNext());
31+
await exit.cancel();
32+
}

0 commit comments

Comments
 (0)