mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 16:59:47 +00:00
[vm] Disable dart:cli waitFor by default
Per breaking change request we are now disabling waitFor by default. Users can still enable it by passing the flag: --enabled-deprecated-wait-for Issue https://github.com/dart-lang/sdk/issues/52121 TEST=standalone/io/wait_for_deprecation_test CoreLibraryReviewExempt: standalone VM only change Change-Id: Ied78f91344d15cb77e932514e2b752bb6ac5dc5d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326021 Commit-Queue: Slava Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Michael Thomsen <mit@google.com>
This commit is contained in:
parent
8d7198661e
commit
61b03b49b1
|
@ -82,6 +82,12 @@ DEFINE_FLAG(bool,
|
|||
dump_tables,
|
||||
false,
|
||||
"Dump common hash tables before snapshotting.");
|
||||
DEFINE_FLAG(bool,
|
||||
enable_deprecated_wait_for,
|
||||
false,
|
||||
"Enable deprecated dart:cli waitFor. "
|
||||
"This feature will be fully removed in Dart 3.4 release. "
|
||||
"See https://dartbug.com/52121.");
|
||||
|
||||
#define CHECK_ERROR_HANDLE(error) \
|
||||
{ \
|
||||
|
@ -2110,6 +2116,17 @@ DART_EXPORT Dart_Handle Dart_HandleMessage() {
|
|||
}
|
||||
|
||||
DART_EXPORT Dart_Handle Dart_WaitForEvent(int64_t timeout_millis) {
|
||||
if (!FLAG_enable_deprecated_wait_for) {
|
||||
return Dart_NewUnhandledExceptionError(Dart_NewStringFromCString(
|
||||
"Synchronous waiting using dart:cli waitFor "
|
||||
"and C API Dart_WaitForEvent is deprecated and disabled by default. "
|
||||
"This feature will be fully removed in Dart 3.4 release. "
|
||||
"You can currently still enable it by passing "
|
||||
"--enable_deprecated_wait_for "
|
||||
"to the Dart VM. "
|
||||
"See https://dartbug.com/52121."));
|
||||
}
|
||||
|
||||
Thread* T = Thread::Current();
|
||||
Isolate* I = T->isolate();
|
||||
CHECK_API_SCOPE(T);
|
||||
|
|
|
@ -71,29 +71,14 @@ class _WaitForUtils {
|
|||
*
|
||||
* ## Deprecation notice
|
||||
*
|
||||
* The `waitFor` feature is deprecated.
|
||||
* The feature was intended to solve a particular problem for existing code,
|
||||
* a problem introduced by a breaking change to the platform libraries.
|
||||
* The `waitFor` function is not suitable for general use.
|
||||
* The feature has shortcomings that can affect other code
|
||||
* running in the same isolate, including:
|
||||
* * A function call that looks synchronous may cause other asynchronous
|
||||
* events to run before it returns.
|
||||
* This is something synchronous code can usually assume not to happen,
|
||||
* and some code may have been written to take advantage of that
|
||||
* assumed behavior. Such code can fail in unexpected ways.
|
||||
* * Multiple nested calls to `waitFor` may block each other
|
||||
* since the most recent call always needs to complete
|
||||
* before any other call can complete.
|
||||
* Judicious use of `waitFor` is necessary to avoid unexpected deadlocks
|
||||
* which wouldn't happen if using `await` instead.
|
||||
* If more than one library in the same program is using `waitFor`,
|
||||
* then it's hard to avoid or control whether such blocking will happen.
|
||||
* The `waitFor` feature is deprecated, disabled by default and slated for
|
||||
* removal in Dart 3.4 release.
|
||||
*
|
||||
* See https://dartbug.com/52121
|
||||
*
|
||||
* During transitionary period you can still force enable this feature
|
||||
* by passing --enable-deprecated-wait-for to Dart VM.
|
||||
*
|
||||
* The feature is not actively maintained.
|
||||
* It will remain as-is to support the original problem it was added to solve,
|
||||
* at least until that problem can be solved in some other way.
|
||||
*
|
||||
* ## Call semantics
|
||||
*
|
||||
* This call does the following:
|
||||
|
@ -137,8 +122,7 @@ class _WaitForUtils {
|
|||
* subsequent calls block waiting for a condition that is only satisfied when
|
||||
* an earlier call returns.
|
||||
*/
|
||||
@Deprecated(
|
||||
"This functionality is incomplete and may be removed in a later version")
|
||||
@Deprecated("This functionality is deprecated and will be removed in Dart 3.4")
|
||||
T waitFor<T>(Future<T> future, {Duration? timeout}) {
|
||||
late T result;
|
||||
bool futureCompleted = false;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
23
tests/standalone/io/wait_for_deprecation_test.dart
Normal file
23
tests/standalone/io/wait_for_deprecation_test.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) 2023, 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.
|
||||
|
||||
// This test verifies that attempting to use `waitFor` without enabling it
|
||||
// causes an exception.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
import 'package:async_helper/async_helper.dart';
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
main() {
|
||||
asyncStart();
|
||||
Expect.throws<String>(() {
|
||||
waitFor(Future.delayed(Duration(milliseconds: 10)).whenComplete(asyncEnd));
|
||||
}, (v) {
|
||||
return v.contains('deprecated and disabled') &&
|
||||
v.contains('dartbug.com/52121') &&
|
||||
v.contains('enable_deprecated_wait_for');
|
||||
});
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:isolate';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:mirrors';
|
||||
import 'dart:cli';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:cli';
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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-deprecated-wait-for
|
||||
|
||||
// @dart = 2.9
|
||||
|
||||
import 'dart:async';
|
||||
|
|
Loading…
Reference in a new issue