Debian Codegraph @

external/rx/Rx/NET/Source/System.Reactive.Linq/Reactive/Linq/Observable/Empty.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 #if !NO_PERF
4 using System;
5 using System.Reactive.Concurrency;
6
7 namespace System.Reactive.Linq.ObservableImpl
8 {
9 class Empty<TResult> : Producer<TResult>
10 {
11 private readonly IScheduler _scheduler;
12
13 public Empty(IScheduler scheduler)
14 {
15 _scheduler = scheduler;
16 }
17
18 protected override IDisposable Run(IObserver<TResult> observer, IDisposable cancel, Action<IDisposable> setSink)
19 {
20 var sink = new _(this, observer, cancel);
21 setSink(sink);
22 return sink.Run();
23 }
24
25 class _ : Sink<TResult>
26 {
27 private readonly Empty<TResult> _parent;
28
29 public _(Empty<TResult> parent, IObserver<TResult> observer, IDisposable cancel)
30 : base(observer, cancel)
31 {
32 _parent = parent;
33 }
34
35 public IDisposable Run()
36 {
37 return _parent._scheduler.Schedule(Invoke);
38 }
39
40 private void Invoke()
41 {
42 base._observer.OnCompleted();
43 base.Dispose();
44 }
45 }
46 }
47 }
48 #endif