Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1623)

Unified Diff: mojo/public/dart/mojo/lib/src/fill_data.dart

Issue 1414483010: Dart: Use a RawReceivePort to receive events for Mojo handles. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/dart/mojo/lib/src/event_stream.dart ('k') | mojo/public/dart/mojo/lib/src/handle.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/mojo/lib/src/fill_data.dart
diff --git a/mojo/public/dart/mojo/lib/src/fill_data.dart b/mojo/public/dart/mojo/lib/src/fill_data.dart
index 848efc2db81e043857fa61b3db39cfb0c779d555..c139a7c3c4c2182d70c4fcf6159c8108a7483f4e 100644
--- a/mojo/public/dart/mojo/lib/src/fill_data.dart
+++ b/mojo/public/dart/mojo/lib/src/fill_data.dart
@@ -7,20 +7,17 @@ part of core;
class DataPipeFiller {
final MojoDataPipeProducer _producer;
final ByteData _data;
- MojoEventStream _eventStream;
+ MojoEventSubscription _eventSubscription;
int _dataPosition;
DataPipeFiller(this._producer, this._data) {
- _eventStream = new MojoEventStream(_producer.handle);
+ _eventSubscription = new MojoEventSubscription(_producer.handle);
_dataPosition = 0;
}
MojoResult _doWrite() {
ByteData view = new ByteData.view(
- _data.buffer,
- _dataPosition,
- _data.lengthInBytes - _dataPosition
- );
+ _data.buffer, _dataPosition, _data.lengthInBytes - _dataPosition);
int written = _producer.write(view);
if (!_producer.status.isOk) {
throw 'Data pipe beginWrite failed: ${_producer.status}';
@@ -30,18 +27,18 @@ class DataPipeFiller {
}
void fill() {
- _eventStream.enableWriteEvents();
- _eventStream.listen((List<int> event) {
+ _eventSubscription.enableWriteEvents();
+ _eventSubscription.subscribe((List<int> event) {
var mojoSignals = new MojoHandleSignals(event[1]);
if (mojoSignals.isWritable) {
MojoResult result = _doWrite();
if (_dataPosition >= _data.lengthInBytes || !result.isOk) {
- _eventStream.close();
- _eventStream = null;
+ _eventSubscription.close();
+ _eventSubscription = null;
}
} else if (mojoSignals.isPeerClosed) {
- _eventStream.close();
- _eventStream = null;
+ _eventSubscription.close();
+ _eventSubscription = null;
} else {
throw 'Unexpected handle event: $mojoSignals';
}
« no previous file with comments | « mojo/public/dart/mojo/lib/src/event_stream.dart ('k') | mojo/public/dart/mojo/lib/src/handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698