mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 22:35:02 +00:00
85700570f6
Fixes #49241 TEST=ci Change-Id: I6117bf816fc8c4613cce66927f952fef75632725 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248120 Reviewed-by: Alexander Thomas <athom@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Ben Konyi <bkonyi@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Commit-Queue: Alexander Thomas <athom@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
43 lines
996 B
Dart
43 lines
996 B
Dart
// Copyright (c) 2017, 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 timer_multiple_isolates_test;
|
|
|
|
import 'dart:isolate';
|
|
import 'dart:async';
|
|
|
|
child(msg) {
|
|
var i = msg[0] as int;
|
|
var responsePort = msg[1];
|
|
print("Starting child $i");
|
|
|
|
// Keep this isolate running to prevent its shutdown from touching the event
|
|
// handler.
|
|
new RawReceivePort();
|
|
|
|
// Try to get separate wakeups for each isolate.
|
|
new Timer(new Duration(milliseconds: 100 * (i + 1)), () {
|
|
print("Timer fired $i");
|
|
responsePort.send(null);
|
|
});
|
|
}
|
|
|
|
main() {
|
|
var port;
|
|
var replies = 0;
|
|
var n = 3;
|
|
port = new RawReceivePort((reply) {
|
|
replies++;
|
|
print("Got reply $replies");
|
|
if (replies == n) {
|
|
print("Done");
|
|
port.close();
|
|
}
|
|
});
|
|
|
|
for (var i = 0; i < n; i++) {
|
|
Isolate.spawn(child, [i, port.sendPort]);
|
|
}
|
|
}
|