From f3e845cf48ecc3a123e45f3d69e4703c7e2b2955 Mon Sep 17 00:00:00 2001 From: Florian Loitsch Date: Thu, 14 Dec 2017 14:10:45 +0000 Subject: [PATCH] Revert "Reland: [dart:io] Adds waitForEventSync" This reverts commit 3ea5e13ad7ceecfe62b24304aecca8c9105037ba. Change-Id: Ic9fae69f3b7ef6e41aac3c7ebca3e1d288dbffb1 Reviewed-on: https://dart-review.googlesource.com/29589 Reviewed-by: Florian Loitsch --- runtime/bin/common.cc | 27 -------- runtime/bin/common_patch.dart | 10 --- runtime/bin/dartutils.cc | 6 -- runtime/bin/io_impl_sources.gni | 1 - runtime/bin/io_natives.cc | 1 - runtime/bin/main.cc | 2 - runtime/include/dart_api.h | 10 --- runtime/lib/isolate_patch.dart | 3 +- runtime/lib/schedule_microtask_patch.dart | 4 -- runtime/vm/compiler/aot/precompiler.cc | 1 - runtime/vm/dart_api_impl.cc | 30 -------- runtime/vm/dart_entry.cc | 14 ---- runtime/vm/dart_entry.h | 5 -- runtime/vm/message_handler.cc | 35 ---------- runtime/vm/message_handler.h | 5 -- runtime/vm/symbols.h | 1 - sdk/lib/io/annotations.dart | 49 ------------- sdk/lib/io/common.dart | 64 ----------------- sdk/lib/io/io.dart | 1 - sdk/lib/io/io_sources.gni | 1 - .../io/wait_for_event_example_test.dart | 39 ----------- .../io/wait_for_event_exception_test.dart | 22 ------ .../io/wait_for_event_isolate_test.dart | 41 ----------- .../io/wait_for_event_microtask_test.dart | 24 ------- .../wait_for_event_nested_microtask_test.dart | 34 --------- ...for_event_nested_timer_microtask_test.dart | 27 -------- .../io/wait_for_event_nested_timer_test.dart | 30 -------- .../io/wait_for_event_nested_waits_test.dart | 69 ------------------- .../io/wait_for_event_timeout_test.dart | 22 ------ .../io/wait_for_event_timer_test.dart | 24 ------- ...wait_for_event_zone_caught_error_test.dart | 29 -------- .../io/wait_for_event_zone_test.dart | 27 -------- ...it_for_event_zone_uncaught_error_test.dart | 24 ------- 33 files changed, 1 insertion(+), 681 deletions(-) delete mode 100644 runtime/bin/common.cc delete mode 100644 sdk/lib/io/annotations.dart delete mode 100644 tests/standalone_2/io/wait_for_event_example_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_exception_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_isolate_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_microtask_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_nested_microtask_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_nested_timer_microtask_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_nested_timer_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_nested_waits_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_timeout_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_timer_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_zone_caught_error_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_zone_test.dart delete mode 100644 tests/standalone_2/io/wait_for_event_zone_uncaught_error_test.dart diff --git a/runtime/bin/common.cc b/runtime/bin/common.cc deleted file mode 100644 index 10f9c4cf38a..00000000000 --- a/runtime/bin/common.cc +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -#include "bin/builtin.h" -#include "bin/dartutils.h" - -#include "include/dart_api.h" - -namespace dart { -namespace bin { - -void FUNCTION_NAME(IOUtils_WaitForEventSync)(Dart_NativeArguments args) { - int64_t timeout_millis; - Dart_Handle result = Dart_GetNativeIntegerArgument(args, 0, &timeout_millis); - if (Dart_IsError(result)) { - Dart_PropagateError(result); - } - result = Dart_WaitForEventSync(timeout_millis); - if (Dart_IsError(result)) { - Dart_PropagateError(result); - } - Dart_SetReturnValue(args, result); -} - -} // namespace bin -} // namespace dart diff --git a/runtime/bin/common_patch.dart b/runtime/bin/common_patch.dart index caed66c57b7..0e46769731c 100644 --- a/runtime/bin/common_patch.dart +++ b/runtime/bin/common_patch.dart @@ -59,13 +59,3 @@ _setupHooks() { VMLibraryHooks.eventHandlerSendData = _EventHandler._sendData; VMLibraryHooks.timerMillisecondClock = _EventHandler._timerMillisecondClock; } - -// The implementation of waitForEventSync for embedders in which the VM -// manages the event loop and microtask queue. -// IOUtils_WaitForEventSync throws an exception if there is an error. -void _standaloneWaitForEventSync(int timeoutMillis) - native "IOUtils_WaitForEventSync"; - -void Function(int timeoutMillis) _getWaitForEventSyncClosure() { - return _standaloneWaitForEventSync; -} diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc index 10a020957e9..e53d6dbc3fb 100644 --- a/runtime/bin/dartutils.cc +++ b/runtime/bin/dartutils.cc @@ -600,12 +600,6 @@ Dart_Handle DartUtils::SetupIOLibrary(const char* namespc_path, Dart_Handle set_script_name = Dart_SetField(platform_type, script_name, dart_script); RETURN_IF_ERROR(set_script_name); - - Dart_Handle wait_for_event = - Dart_Invoke(io_lib, NewString("_getWaitForEventSyncClosure"), 0, NULL); - RETURN_IF_ERROR(wait_for_event); - RETURN_IF_ERROR(Dart_SetField(io_lib, NewString("_waitForEventSyncImpl"), - wait_for_event)); return Dart_Null(); } diff --git a/runtime/bin/io_impl_sources.gni b/runtime/bin/io_impl_sources.gni index 87c6462e4f5..408652f69b6 100644 --- a/runtime/bin/io_impl_sources.gni +++ b/runtime/bin/io_impl_sources.gni @@ -5,7 +5,6 @@ # This file contains some C++ sources for the dart:io library. The other # implementation files are in builtin_impl_sources.gypi. io_impl_sources = [ - "common.cc", "eventhandler.cc", "eventhandler.h", "eventhandler_android.cc", diff --git a/runtime/bin/io_natives.cc b/runtime/bin/io_natives.cc index eb3550be616..9ecb61da120 100644 --- a/runtime/bin/io_natives.cc +++ b/runtime/bin/io_natives.cc @@ -81,7 +81,6 @@ namespace bin { V(Filter_Processed, 3) \ V(InternetAddress_Parse, 1) \ V(IOService_NewServicePort, 0) \ - V(IOUtils_WaitForEventSync, 1) \ V(Namespace_Create, 2) \ V(Namespace_GetDefault, 0) \ V(Namespace_GetPointer, 1) \ diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc index 122fb64755e..c030a711c8a 100644 --- a/runtime/bin/main.cc +++ b/runtime/bin/main.cc @@ -676,8 +676,6 @@ static Dart_QualifiedFunctionName standalone_entry_points[] = { {"dart:io", "::", "_makeDatagram"}, {"dart:io", "::", "_makeUint8ListView"}, {"dart:io", "::", "_setupHooks"}, - {"dart:io", "::", "_getWaitForEventSyncClosure"}, - {"dart:io", "::", "_waitForEventSyncImpl"}, {"dart:io", "_EmbedderConfig", "_mayExit"}, {"dart:io", "_ExternalBuffer", "get:end"}, {"dart:io", "_ExternalBuffer", "get:start"}, diff --git a/runtime/include/dart_api.h b/runtime/include/dart_api.h index fec0c2fb74e..f14e08b3247 100644 --- a/runtime/include/dart_api.h +++ b/runtime/include/dart_api.h @@ -1215,16 +1215,6 @@ DART_EXPORT Dart_Handle Dart_HandleMessage(); */ DART_EXPORT Dart_Handle Dart_HandleMessages(); -/** - * Drains the microtask queue, then blocks the calling thread until the current - * isolate recieves a message, then handles all messages. - * - * \param timeout_millis When non-zero, the call returns after the indicated - number of milliseconds even if no message was received. - * \return A valid handle if no error occurs, otherwise an error handle. - */ -DART_EXPORT Dart_Handle Dart_WaitForEventSync(int64_t timeout_millis); - /** * Handles any pending messages for the vm service for the current * isolate. diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart index ad4f63b55d0..99cb61b1374 100644 --- a/runtime/lib/isolate_patch.dart +++ b/runtime/lib/isolate_patch.dart @@ -100,8 +100,7 @@ _ImmediateCallback _pendingImmediateCallback; /// The closure that should be used as scheduleImmediateClosure, when the VM /// is responsible for the event loop. void _isolateScheduleImmediate(void callback()) { - assert((_pendingImmediateCallback == null) || - (_pendingImmediateCallback == callback)); + assert(_pendingImmediateCallback == null); _pendingImmediateCallback = callback; } diff --git a/runtime/lib/schedule_microtask_patch.dart b/runtime/lib/schedule_microtask_patch.dart index 4dc837ddd38..d450e8c9872 100644 --- a/runtime/lib/schedule_microtask_patch.dart +++ b/runtime/lib/schedule_microtask_patch.dart @@ -24,7 +24,3 @@ class _ScheduleImmediate { void _setScheduleImmediateClosure(_ScheduleImmediateClosure closure) { _ScheduleImmediate._closure = closure; } - -void _ensureScheduleImmediate() { - _AsyncRun._scheduleImmediate(_startMicrotaskLoop); -} diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc index 07dd9e6f06a..b07b481986d 100644 --- a/runtime/vm/compiler/aot/precompiler.cc +++ b/runtime/vm/compiler/aot/precompiler.cc @@ -626,7 +626,6 @@ void Precompiler::PrecompileConstructors() { static Dart_QualifiedFunctionName vm_entry_points[] = { // Functions - {"dart:async", "::", "_ensureScheduleImmediate"}, {"dart:core", "::", "_completeDeferredLoads"}, {"dart:core", "::", "identityHashCode"}, {"dart:core", "AbstractClassInstantiationError", diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 92668c2cdca..df541f8285d 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -1672,36 +1672,6 @@ DART_EXPORT Dart_Handle Dart_HandleMessages() { return Api::Success(); } -DART_EXPORT Dart_Handle Dart_WaitForEventSync(int64_t timeout_millis) { - Thread* T = Thread::Current(); - Isolate* I = T->isolate(); - CHECK_API_SCOPE(T); - CHECK_CALLBACK_STATE(T); - API_TIMELINE_BEGIN_END_BASIC; - TransitionNativeToVM transition(T); - if (I->message_notify_callback() != NULL) { - return Api::NewError("waitForEventSync is not supported by this embedder"); - } - // NB: If waitForEventSync() is moved from dart:io to dart:async, then - // this call can be made from Dart code instead of from the runtime. - Object& result = - Object::Handle(Z, DartLibraryCalls::EnsureScheduleImmediate()); - if (result.IsError()) { - return Api::NewHandle(T, result.raw()); - } - result = DartLibraryCalls::DrainMicrotaskQueue(); - if (result.IsError()) { - return Api::NewHandle(T, result.raw()); - } - if (I->message_handler()->PauseAndHandleAllMessages(timeout_millis) != - MessageHandler::kOK) { - Dart_Handle error = Api::NewHandle(T, T->sticky_error()); - T->clear_sticky_error(); - return error; - } - return Api::Success(); -} - DART_EXPORT bool Dart_HandleServiceMessages() { #if defined(PRODUCT) return true; diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc index bff99238de2..5fab765d1ef 100644 --- a/runtime/vm/dart_entry.cc +++ b/runtime/vm/dart_entry.cc @@ -665,20 +665,6 @@ RawObject* DartLibraryCalls::DrainMicrotaskQueue() { return result.raw(); } -RawObject* DartLibraryCalls::EnsureScheduleImmediate() { - Zone* zone = Thread::Current()->zone(); - const Library& async_lib = Library::Handle(zone, Library::AsyncLibrary()); - ASSERT(!async_lib.IsNull()); - const Function& function = - Function::Handle(zone, async_lib.LookupFunctionAllowPrivate( - Symbols::_ensureScheduleImmediate())); - ASSERT(!function.IsNull()); - const Object& result = Object::Handle( - zone, DartEntry::InvokeFunction(function, Object::empty_array())); - ASSERT(result.IsNull() || result.IsError()); - return result.raw(); -} - RawObject* DartLibraryCalls::MapSetAt(const Instance& map, const Instance& key, const Instance& value) { diff --git a/runtime/vm/dart_entry.h b/runtime/vm/dart_entry.h index d28a5cd68f6..79ba34bd9ee 100644 --- a/runtime/vm/dart_entry.h +++ b/runtime/vm/dart_entry.h @@ -282,11 +282,6 @@ class DartLibraryCalls : public AllStatic { // Returns null on success, a RawError on failure. static RawObject* DrainMicrotaskQueue(); - // Ensures that the isolate's _pendingImmediateCallback is set to - // _startMicrotaskLoop from dart:async. - // Returns null on success, a RawError on failure. - static RawObject* EnsureScheduleImmediate(); - // map[key] = value; // // Returns null on success, a RawError on failure. diff --git a/runtime/vm/message_handler.cc b/runtime/vm/message_handler.cc index cea057ae0a0..e35d72a3d0c 100644 --- a/runtime/vm/message_handler.cc +++ b/runtime/vm/message_handler.cc @@ -54,7 +54,6 @@ MessageHandler::MessageHandler() : queue_(new MessageQueue()), oob_queue_(new MessageQueue()), oob_message_handling_allowed_(true), - paused_for_messages_(false), live_ports_(0), paused_(0), #if !defined(PRODUCT) @@ -152,9 +151,6 @@ void MessageHandler::PostMessage(Message* message, bool before_events) { } else { queue_->Enqueue(message, before_events); } - if (paused_for_messages_) { - ml.Notify(); - } message = NULL; // Do not access message. May have been deleted. if ((pool_ != NULL) && (task_ == NULL)) { @@ -280,37 +276,6 @@ MessageHandler::MessageStatus MessageHandler::HandleAllMessages() { return HandleMessages(&ml, true, true); } -MessageHandler::MessageStatus MessageHandler::PauseAndHandleAllMessages( - int64_t timeout_millis) { - MonitorLocker ml(&monitor_); - ASSERT(task_ != NULL); - ASSERT(!delete_me_); -#if defined(DEBUG) - CheckAccess(); -#endif - paused_for_messages_ = true; - while (queue_->IsEmpty() && oob_queue_->IsEmpty()) { - Monitor::WaitResult wr = ml.Wait(timeout_millis); - ASSERT(task_ != NULL); - ASSERT(!delete_me_); - if (wr == Monitor::kTimedOut) { - paused_for_messages_ = false; - return kOK; - } - if (queue_->IsEmpty()) { - // There are only OOB messages. Handle them and then continue waiting for - // normal messages unless there is an error. - MessageStatus status = HandleMessages(&ml, false, false); - if (status != kOK) { - paused_for_messages_ = false; - return status; - } - } - } - paused_for_messages_ = false; - return HandleMessages(&ml, true, true); -} - MessageHandler::MessageStatus MessageHandler::HandleOOBMessages() { if (!oob_message_handling_allowed_) { return kOK; diff --git a/runtime/vm/message_handler.h b/runtime/vm/message_handler.h index 312b013aae2..d34b05b8c3e 100644 --- a/runtime/vm/message_handler.h +++ b/runtime/vm/message_handler.h @@ -70,10 +70,6 @@ class MessageHandler { // Returns true on success. MessageStatus HandleOOBMessages(); - // Blocks the thread on a condition variable until a message arrives, and then - // handles all messages. - MessageStatus PauseAndHandleAllMessages(int64_t timeout_millis); - // Returns true if there are pending OOB messages for this message // handler. bool HasOOBMessages(); @@ -236,7 +232,6 @@ class MessageHandler { // This flag is not thread safe and can only reliably be accessed on a single // thread. bool oob_message_handling_allowed_; - bool paused_for_messages_; intptr_t live_ports_; // The number of open ports, including control ports. intptr_t paused_; // The number of pause messages received. #if !defined(PRODUCT) diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h index 0d2dfcd79ed..5c7f208741b 100644 --- a/runtime/vm/symbols.h +++ b/runtime/vm/symbols.h @@ -430,7 +430,6 @@ class ObjectPointerVisitor; V(ConstructorStacktracePrefix, "new ") \ V(_runExtension, "_runExtension") \ V(_runPendingImmediateCallback, "_runPendingImmediateCallback") \ - V(_ensureScheduleImmediate, "_ensureScheduleImmediate") \ V(DartLibrary, "dart.library.") \ V(DartLibraryMirrors, "dart.library.mirrors") \ V(_name, "_name") \ diff --git a/sdk/lib/io/annotations.dart b/sdk/lib/io/annotations.dart deleted file mode 100644 index d91d30b330b..00000000000 --- a/sdk/lib/io/annotations.dart +++ /dev/null @@ -1,49 +0,0 @@ -// 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. - -part of dart.io; - -/** - * The annotation `@Experimental('message')` marks a feature as experimental. - * - * The annotation `@experimental` is shorthand that uses the default message - * "This feature is experimental and not intended for general use". - * - * The intent of the `@Experimental` annotation is to inform users that a - * feature has one ore more of the following issues: - * - It is not yet stable, - * - It may not work as documented, - * - It should only be used by experts, - * - It is not available in all environments. - * - * The documentation for an experimental feature should explain which of these - * apply, and ideally give a reasonably safe example usage. - * - * A tool that processes Dart source code may give reports when experimental - * features are used similarly to how they give reports for features marked - * with the [Deprecated] annotation. - */ -class Experimental { - /** - * A brief message describing how or why the feature is experimental. - */ - final String message; - - const Experimental({String message}) : this.message = message; - - @override - String toString() { - if (message == null) { - return "This feature is experimental, and not intended for general use."; - } else { - return "This feature is experimental: $message"; - } - } -} - -/** - * Marks a feature as experimental with the message, "Not intended for - * general use". - */ -const Experimental experimental = const Experimental(); diff --git a/sdk/lib/io/common.dart b/sdk/lib/io/common.dart index 73937453ae0..ae9cd1256f1 100644 --- a/sdk/lib/io/common.dart +++ b/sdk/lib/io/common.dart @@ -117,67 +117,3 @@ _BufferAndStart _ensureFastAndSerializableByteData( class _IOCrypto { external static Uint8List getRandomBytes(int count); } - -// The implementation of waitForEventSync if there is one, and null otherwise. -void Function(int timeoutMillis) _waitForEventSyncImpl; - -/** - * Synchronously blocks the calling isolate to wait for asynchronous events to - * complete. - * - * WARNING: EXPERIMENTAL. USE AT YOUR OWN RISK. - * - * If the [timeout] parameter is supplied, [waitForEventSync] will return after - * the specified timeout even if no events have occurred. - * - * This call does the following: - * - suspends the current execution stack, - * - runs the microtask queue until it is empty, - * - waits until the event queue is not empty, - * - handles events on the event queue, plus their associated microtasks, - * until the event queue is empty, - * - resumes the original stack. - * - * This function will synchronously throw the first exception it encounters in - * running the microtasks and event handlers, leaving the remaining microtasks - * and events on their respective queues. - * - * Please note that this call is only safe to make in code that is running in - * the standalone command-line Dart VM. Further, because it suspends the current - * execution stack until all other events have been processed, even when running - * in the standalone command-line VM there exists a risk that the current - * execution stack will be starved. - * - * Example: - * - * ``` - * main() { - * bool condition = false; - * ... - * // Some asynchronous opertion that eventually sets 'condition' true. - * ... - * print("Waiting for 'condition'"); - * Duration timeout = const Duration(seconds: 10); - * Timer.run(() {}); // Ensure that there is at least one event. - * Stopwatch s = new Stopwatch()..start(); - * while (!condition) { - * if (s.elapsed > timeout) { - * print("timed out waiting for 'condition'!"); - * break; - * } - * print("still waiting..."); - * waitForEventSync(timeout: timeout); - * } - * s.stop(); - * } - * ``` - */ -@Experimental(message: "This feature is only available in the standalone VM") -void waitForEventSync({Duration timeout}) { - if (_waitForEventSyncImpl == null) { - throw new UnsupportedError( - "waitForEventSync is not supported on this platform"); - } - final int timeout_millis = timeout == null ? 0 : timeout.inMilliseconds; - _waitForEventSyncImpl(timeout_millis); -} diff --git a/sdk/lib/io/io.dart b/sdk/lib/io/io.dart index 0789d5e559e..ce9dbd0f360 100644 --- a/sdk/lib/io/io.dart +++ b/sdk/lib/io/io.dart @@ -205,7 +205,6 @@ import 'dart:typed_data'; export 'dart:_http'; -part 'annotations.dart'; part 'bytes_builder.dart'; part 'common.dart'; part 'data_transformer.dart'; diff --git a/sdk/lib/io/io_sources.gni b/sdk/lib/io/io_sources.gni index 13ec96b1ef1..51e283a990e 100644 --- a/sdk/lib/io/io_sources.gni +++ b/sdk/lib/io/io_sources.gni @@ -6,7 +6,6 @@ io_sdk_sources = [ "io.dart", # The above file needs to be first if additional parts are added to the lib. - "annotations.dart", "bytes_builder.dart", "common.dart", "data_transformer.dart", diff --git a/tests/standalone_2/io/wait_for_event_example_test.dart b/tests/standalone_2/io/wait_for_event_example_test.dart deleted file mode 100644 index f5c8615a812..00000000000 --- a/tests/standalone_2/io/wait_for_event_example_test.dart +++ /dev/null @@ -1,39 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that example code in the doc comment for waitForEventSync is okay. - -main() { - asyncStart(); - bool condition = false; - - new Timer(const Duration(seconds: 2), () { - asyncEnd(); - condition = true; - }); - - Duration timeout = const Duration(milliseconds: 100); - Timer.run(() {}); // Ensure that there is at least one event. - Stopwatch s = new Stopwatch()..start(); - while (!condition) { - if (s.elapsed > timeout) { - break; - } - waitForEventSync(timeout: timeout); - } - s.stop(); - - Expect.isFalse(condition); - while (!condition) { - waitForEventSync(); - } - Expect.isTrue(condition); -} diff --git a/tests/standalone_2/io/wait_for_event_exception_test.dart b/tests/standalone_2/io/wait_for_event_exception_test.dart deleted file mode 100644 index d34adcb3de1..00000000000 --- a/tests/standalone_2/io/wait_for_event_exception_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that exceptions thrown by message handlers running under -// waitForEventSync() are propagated synchronously. - -main() { - asyncStart(); - Timer.run(() { - asyncEnd(); - throw "Exception"; - }); - Expect.throws(waitForEventSync, (e) => e is String); -} diff --git a/tests/standalone_2/io/wait_for_event_isolate_test.dart b/tests/standalone_2/io/wait_for_event_isolate_test.dart deleted file mode 100644 index afa4cc5d452..00000000000 --- a/tests/standalone_2/io/wait_for_event_isolate_test.dart +++ /dev/null @@ -1,41 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that waitForEventSync() returns on an Isolate message. - -messageSender(SendPort s) { - new Timer(const Duration(seconds: 1), () { - s.send(true); - }); -} - -main() { - asyncStart(); - bool flag1 = false; - bool flag2 = false; - ReceivePort r = new ReceivePort(); - Isolate.spawn(messageSender, r.sendPort).then((Isolate i) { - r.listen((message) { - flag1 = true; - }); - Expect.isFalse(flag1); - waitForEventSync(); - Expect.isTrue(flag1); - r.close(); - flag2 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - waitForEventSync(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - asyncEnd(); -} diff --git a/tests/standalone_2/io/wait_for_event_microtask_test.dart b/tests/standalone_2/io/wait_for_event_microtask_test.dart deleted file mode 100644 index b7443ed672e..00000000000 --- a/tests/standalone_2/io/wait_for_event_microtask_test.dart +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that microtasks are run before waitForEventSync() blocks. - -main() { - asyncStart(); - bool flag = false; - scheduleMicrotask(() { - flag = true; - asyncEnd(); - }); - Expect.isFalse(flag); - waitForEventSync(timeout: const Duration(milliseconds: 10)); - Expect.isTrue(flag); -} diff --git a/tests/standalone_2/io/wait_for_event_nested_microtask_test.dart b/tests/standalone_2/io/wait_for_event_nested_microtask_test.dart deleted file mode 100644 index 22944ca7fb1..00000000000 --- a/tests/standalone_2/io/wait_for_event_nested_microtask_test.dart +++ /dev/null @@ -1,34 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that waitForEventSync() drains microtasks before blocking even when -// called from a microtask. - -main() { - asyncStart(); - bool flag1 = false; - bool flag2 = false; - scheduleMicrotask(() { - scheduleMicrotask(() { - flag1 = true; - asyncEnd(); - }); - Expect.isFalse(flag1); - waitForEventSync(timeout: const Duration(milliseconds: 10)); - Expect.isTrue(flag1); - flag2 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - waitForEventSync(timeout: const Duration(milliseconds: 10)); - Expect.isTrue(flag1); - Expect.isTrue(flag2); -} diff --git a/tests/standalone_2/io/wait_for_event_nested_timer_microtask_test.dart b/tests/standalone_2/io/wait_for_event_nested_timer_microtask_test.dart deleted file mode 100644 index 17d58b70720..00000000000 --- a/tests/standalone_2/io/wait_for_event_nested_timer_microtask_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that the microtasks for a message handler are run before -// waitForEventSync() returns. - -main() { - asyncStart(); - bool flag = false; - Timer.run(() { - scheduleMicrotask(() { - flag = true; - asyncEnd(); - }); - }); - Expect.isFalse(flag); - waitForEventSync(); - Expect.isTrue(flag); -} diff --git a/tests/standalone_2/io/wait_for_event_nested_timer_test.dart b/tests/standalone_2/io/wait_for_event_nested_timer_test.dart deleted file mode 100644 index ed58608b345..00000000000 --- a/tests/standalone_2/io/wait_for_event_nested_timer_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that all messages are processed before waitForEventSync() returns. - -main() { - asyncStart(); - bool flag = false; - Timer.run(() { - Timer.run(() { - Timer.run(() { - Timer.run(() { - flag = true; - asyncEnd(); - }); - }); - }); - }); - Expect.isFalse(flag); - waitForEventSync(); - Expect.isTrue(flag); -} diff --git a/tests/standalone_2/io/wait_for_event_nested_waits_test.dart b/tests/standalone_2/io/wait_for_event_nested_waits_test.dart deleted file mode 100644 index 7f831d16d5d..00000000000 --- a/tests/standalone_2/io/wait_for_event_nested_waits_test.dart +++ /dev/null @@ -1,69 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that waitForEventSync() works when called from a message handler. - -main() { - asyncStart(); - bool flag1 = false; - bool flag2 = false; - bool flag3 = false; - bool flag4 = false; - Timer.run(() { - Timer.run(() { - Timer.run(() { - Timer.run(() { - flag1 = true; - asyncEnd(); - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEventSync(); - Expect.isTrue(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - flag2 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEventSync(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - flag3 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEventSync(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - Expect.isTrue(flag3); - Expect.isFalse(flag4); - flag4 = true; - }); - Expect.isFalse(flag1); - Expect.isFalse(flag2); - Expect.isFalse(flag3); - Expect.isFalse(flag4); - waitForEventSync(); - Expect.isTrue(flag1); - Expect.isTrue(flag2); - Expect.isTrue(flag3); - Expect.isTrue(flag4); -} diff --git a/tests/standalone_2/io/wait_for_event_timeout_test.dart b/tests/standalone_2/io/wait_for_event_timeout_test.dart deleted file mode 100644 index d8536065284..00000000000 --- a/tests/standalone_2/io/wait_for_event_timeout_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that waitForEventSync() respects its 'timeout' parameter. - -main() { - asyncStart(); - Duration t = const Duration(seconds: 1); - Stopwatch s = new Stopwatch()..start(); - waitForEventSync(timeout: t); - s.stop(); - Expect.isTrue(s.elapsed > t); - asyncEnd(); -} diff --git a/tests/standalone_2/io/wait_for_event_timer_test.dart b/tests/standalone_2/io/wait_for_event_timer_test.dart deleted file mode 100644 index 870d972138e..00000000000 --- a/tests/standalone_2/io/wait_for_event_timer_test.dart +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that waitForEventSync() works in a simple case. - -main() { - asyncStart(); - bool flag = false; - Timer.run(() { - flag = true; - asyncEnd(); - }); - Expect.isFalse(flag); - waitForEventSync(); - Expect.isTrue(flag); -} diff --git a/tests/standalone_2/io/wait_for_event_zone_caught_error_test.dart b/tests/standalone_2/io/wait_for_event_zone_caught_error_test.dart deleted file mode 100644 index cdf86975df5..00000000000 --- a/tests/standalone_2/io/wait_for_event_zone_caught_error_test.dart +++ /dev/null @@ -1,29 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that waitForEventSync() doesn't cause an error to escape a Zone that -// has an error handler. - -main() { - asyncStart(); - bool flag = false; - runZoned(() { - Timer.run(() { - asyncEnd(); - throw "Exception"; - }); - }, onError: (e) { - flag = true; - }); - Expect.isFalse(flag); - waitForEventSync(); - Expect.isTrue(flag); -} diff --git a/tests/standalone_2/io/wait_for_event_zone_test.dart b/tests/standalone_2/io/wait_for_event_zone_test.dart deleted file mode 100644 index de989a4150b..00000000000 --- a/tests/standalone_2/io/wait_for_event_zone_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that waitForEventSync() works even when the message handler is run in -// a different Zone. - -main() { - asyncStart(); - bool flag = false; - runZoned(() { - Timer.run(() { - flag = true; - asyncEnd(); - }); - }); - Expect.isFalse(flag); - waitForEventSync(); - Expect.isTrue(flag); -} diff --git a/tests/standalone_2/io/wait_for_event_zone_uncaught_error_test.dart b/tests/standalone_2/io/wait_for_event_zone_uncaught_error_test.dart deleted file mode 100644 index 8799c457539..00000000000 --- a/tests/standalone_2/io/wait_for_event_zone_uncaught_error_test.dart +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -import 'dart:async'; -import 'dart:io'; -import 'dart:isolate'; - -import 'package:async_helper/async_helper.dart'; -import 'package:expect/expect.dart'; - -// Tests that an exception thrown from a message handler in a Zone without an -// error handler is propagated synchronously. - -main() { - asyncStart(); - runZoned(() { - Timer.run(() { - asyncEnd(); - throw "Exception"; - }); - }); - Expect.throws(waitForEventSync, (e) => e is String); -}