[vm/isolate_api] Fix thread-starting race in threading_test.
Fixes https://github.com/dart-lang/sdk/issues/63526 TEST=ci Change-Id: I7e0a52d3c5a7c04c1d853f769544547758c49545 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509541 Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Alexander Aprelev <aam@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
eb979c2f0c
commit
4f2ee94e20
@@ -251,11 +251,15 @@ Future<void> testFailRunSyncOnPinnedIsolate() async {
|
||||
threadInfo.join();
|
||||
}
|
||||
|
||||
@pragma('vm:shared')
|
||||
bool isHelperInThreadMainWaitingLatchRunning = false;
|
||||
|
||||
int threadMainWaitingLatch(Pointer<Void> data) {
|
||||
final helper = Isolate.create(debugName: "helper");
|
||||
|
||||
sp.send(helper);
|
||||
helper.runSync(() {
|
||||
isHelperInThreadMainWaitingLatchRunning = true;
|
||||
waitLatch();
|
||||
});
|
||||
print('shutting down the isolate');
|
||||
@@ -269,8 +273,13 @@ Future<void> testFailRunSyncWithTimeout() async {
|
||||
}
|
||||
|
||||
final completer = Completer();
|
||||
final rp = RawReceivePort((Isolate child_isolate) {
|
||||
final rp = RawReceivePort((Isolate child_isolate) async {
|
||||
print('received $child_isolate');
|
||||
while (!isHelperInThreadMainWaitingLatchRunning) {
|
||||
// Let the thread which should do `helper.runSync`
|
||||
// actually do that.
|
||||
await Future.delayed(Duration(milliseconds: 10));
|
||||
}
|
||||
Expect.throws(
|
||||
() => child_isolate.runSync(() {
|
||||
Expect.fail("Should not run");
|
||||
|
||||
Reference in New Issue
Block a user