提交 231b2882 编写于 作者: I Ian Hickson 提交者: GitHub

Revert "Make drain() consistently asynchronous. (#21062)"

This reverts commit cdc631c4.
上级 5e9b235b
......@@ -181,11 +181,7 @@ class ChannelBuffers {
///
/// This should be called once a channel is prepared to handle messages
/// (i.e. when a message handler is setup in the framework).
///
/// The messages are processed by calling the given `callback`. Each message
/// is processed in its own microtask.
Future<void> drain(String channel, DrainChannelCallback callback) async {
await null; // Ensures that the rest of this method is scheduled in a microtask.
while (!_isEmpty(channel)) {
final _StoredMessage message = _pop(channel)!;
await callback(message.data, message.callback);
......
......@@ -119,7 +119,6 @@ class ChannelBuffers {
}
Future<void> drain(String channel, DrainChannelCallback callback) async {
await null; // Ensures that the rest of this method is scheduled in a microtask.
while (!_isEmpty(channel)) {
final _StoredMessage message = _pop(channel)!;
await callback(message.data, message.callback);
......
......@@ -3,8 +3,6 @@
// found in the LICENSE file.
// @dart = 2.6
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'dart:ui' as ui;
......@@ -36,32 +34,6 @@ void main() {
});
});
test('drain is async', () async {
const String channel = 'foo';
final ByteData data = _makeByteData('message');
final ui.ChannelBuffers buffers = ui.ChannelBuffers();
final ui.PlatformMessageResponseCallback callback = (ByteData responseData) {};
buffers.push(channel, data, callback);
final List<String> log = <String>[];
final Completer<void> completer = Completer<void>();
scheduleMicrotask(() { log.add('before drain, microtask'); });
log.add('before drain');
buffers.drain(channel, (ByteData drainedData, ui.PlatformMessageResponseCallback drainedCallback) async {
log.add('callback');
completer.complete();
});
log.add('after drain, before await');
await completer.future;
log.add('after await');
expect(log, <String>[
'before drain',
'after drain, before await',
'before drain, microtask',
'callback',
'after await'
]);
});
test('push drain zero', () async {
const String channel = 'foo';
final ByteData data = _makeByteData('bar');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册