You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
909 B
33 lines
909 B
using System; |
|
using System.Threading; |
|
|
|
namespace UniRx.Operators |
|
{ |
|
public abstract class OperatorObserverBase<TSource, TResult> : IDisposable, IObserver<TSource> |
|
{ |
|
protected internal volatile IObserver<TResult> observer; |
|
IDisposable cancel; |
|
|
|
public OperatorObserverBase(IObserver<TResult> observer, IDisposable cancel) |
|
{ |
|
this.observer = observer; |
|
this.cancel = cancel; |
|
} |
|
|
|
public abstract void OnNext(TSource value); |
|
|
|
public abstract void OnError(Exception error); |
|
|
|
public abstract void OnCompleted(); |
|
|
|
public void Dispose() |
|
{ |
|
observer = UniRx.InternalUtil.EmptyObserver<TResult>.Instance; |
|
var target = System.Threading.Interlocked.Exchange(ref cancel, null); |
|
if (target != null) |
|
{ |
|
target.Dispose(); |
|
} |
|
} |
|
} |
|
} |