浏览代码

stream

/main
siyao 3 年前
当前提交
9aea53eb
共有 4 个文件被更改,包括 641 次插入457 次删除
  1. 2
      com.unity.uiwidgets/Runtime/async/async_cast.cs
  2. 8
      com.unity.uiwidgets/Runtime/async/broadcast_stream_controller.cs
  3. 998
      com.unity.uiwidgets/Runtime/async/stream.cs
  4. 90
      com.unity.uiwidgets/Runtime/async/stream_impl.cs

2
com.unity.uiwidgets/Runtime/async/async_cast.cs


class CastStreamTransformer<SS, ST, TS, TT>
: StreamTransformerBase<TS, TT> where TT : class where ST : class {
: StreamTransformerBase<TS, TT> where TT : class where ST : class where SS : class {
public readonly StreamTransformer<SS, ST> _source;
public CastStreamTransformer(StreamTransformer<SS, ST> _source) {

8
com.unity.uiwidgets/Runtime/async/broadcast_stream_controller.cs


// * an "asBroadcastStream" stream are always initiated by events
// * on another stream, and it is fine to forward them synchronously.
// */
// class _AsBroadcastStreamController<T> extends _SyncBroadcastStreamController<T>
// implements _EventDispatch<T> {
// class _AsBroadcastStreamController<T> : _SyncBroadcastStreamController<T>
// , _EventDispatch<T> {
// _AsBroadcastStreamController(void onListen(), void onCancel())
// : base(onListen, onCancel);
// _AsBroadcastStreamController(Action onListen, Action onCancel)
// : base(()=>onListen(), onCancel);
//
// bool get _hasPending => _pending != null && !_pending.isEmpty;
//

998
com.unity.uiwidgets/Runtime/async/stream.cs
文件差异内容过多而无法显示
查看文件

90
com.unity.uiwidgets/Runtime/async/stream_impl.cs


internal delegate _PendingEvents<T> _EventGenerator<T>();
internal delegate void _BroadcastCallback<T>(StreamSubscription<T> subscription);
}
abstract class _StreamImpl<T> : Stream<T> {

if (_onDone != null) _zone.runGuarded(() => _onDone);
}
}
// class _AsBroadcastStream<T> : Stream<T> {
// readonly Stream<T> _source;
// readonly _stream._BroadcastCallback<T> _onListenHandler;
// readonly _stream._BroadcastCallback<T> _onCancelHandler;
// readonly Zone _zone;
//
// _AsBroadcastStreamController<T> _controller;
// StreamSubscription<T> _subscription;
//
// _AsBroadcastStream(
// this._source,
// void onListenHandler(StreamSubscription<T> subscription),
// void onCancelHandler(StreamSubscription<T> subscription))
// // TODO(floitsch): the return type should be void and should be
// // inferred.
// : _onListenHandler = Zone.current
// .registerUnaryCallback<dynamic, StreamSubscription<T>>(
// onListenHandler),
// _onCancelHandler = Zone.current
// .registerUnaryCallback<dynamic, StreamSubscription<T>>(
// onCancelHandler),
// _zone = Zone.current {
// _controller = new _AsBroadcastStreamController<T>(_onListen, _onCancel);
// }
//
// bool get isBroadcast => true;
//
// StreamSubscription<T> listen(void onData(T data),
// {Function onError, void onDone(), bool cancelOnError}) {
// if (_controller == null || _controller.isClosed) {
// // Return a dummy subscription backed by nothing, since
// // it will only ever send one done event.
// return new _DoneStreamSubscription<T>(onDone);
// }
// _subscription ??= _source.listen(_controller.add,
// onError: _controller.addError, onDone: _controller.close);
// cancelOnError = identical(true, cancelOnError);
// return _controller._subscribe(onData, onError, onDone, cancelOnError);
// }
//
// void _onCancel() {
// bool shutdown = (_controller == null) || _controller.isClosed;
// if (_onCancelHandler != null) {
// _zone.runUnary(
// _onCancelHandler, new _BroadcastSubscriptionWrapper<T>(this));
// }
// if (shutdown) {
// if (_subscription != null) {
// _subscription.cancel();
// _subscription = null;
// }
// }
// }
//
// void _onListen() {
// if (_onListenHandler != null) {
// _zone.runUnary(
// _onListenHandler, new _BroadcastSubscriptionWrapper<T>(this));
// }
// }
//
// // Methods called from _BroadcastSubscriptionWrapper.
// void _cancelSubscription() {
// if (_subscription == null) return;
// // Called by [_controller] when it has no subscribers left.
// StreamSubscription subscription = _subscription;
// _subscription = null;
// _controller = null; // Marks the stream as no longer listenable.
// subscription.cancel();
// }
//
// void _pauseSubscription(Future resumeSignal) {
// if (_subscription == null) return;
// _subscription.pause(resumeSignal);
// }
//
// void _resumeSubscription() {
// if (_subscription == null) return;
// _subscription.resume();
// }
//
// bool get _isSubscriptionPaused {
// if (_subscription == null) return false;
// return _subscription.isPaused;
// }
// }
internal class _StreamIterator<T> : StreamIterator<T> {
StreamSubscription<T> _subscription;

正在加载...
取消
保存