[go: nahoru, domu]

Skip to content

Commit

Permalink
Revert "Make drain() consistently asynchronous. (flutter#21062)" (flu…
Browse files Browse the repository at this point in the history
…tter#21391)

This reverts commit cdc631c.
  • Loading branch information
Hixie committed Sep 25, 2020
1 parent d9e7d65 commit ee71df7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 33 deletions.
4 changes: 0 additions & 4 deletions lib/ui/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/lib/src/ui/channel_buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 0 additions & 28 deletions testing/dart/channel_buffers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit ee71df7

Please sign in to comment.