Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/rx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Rx.NET/System.Reactive.Core/Reactive/Internal/CheckedObserver.cs')
-rw-r--r--Rx.NET/System.Reactive.Core/Reactive/Internal/CheckedObserver.cs73
1 files changed, 0 insertions, 73 deletions
diff --git a/Rx.NET/System.Reactive.Core/Reactive/Internal/CheckedObserver.cs b/Rx.NET/System.Reactive.Core/Reactive/Internal/CheckedObserver.cs
deleted file mode 100644
index 7097027..0000000
--- a/Rx.NET/System.Reactive.Core/Reactive/Internal/CheckedObserver.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System;
-using System.Threading;
-
-namespace System.Reactive
-{
- internal class CheckedObserver<T> : IObserver<T>
- {
- private readonly IObserver<T> _observer;
- private int _state;
-
- private const int IDLE = 0;
- private const int BUSY = 1;
- private const int DONE = 2;
-
- public CheckedObserver(IObserver<T> observer)
- {
- _observer = observer;
- }
-
- public void OnNext(T value)
- {
- CheckAccess();
-
- try
- {
- _observer.OnNext(value);
- }
- finally
- {
- Interlocked.Exchange(ref _state, IDLE);
- }
- }
-
- public void OnError(Exception error)
- {
- CheckAccess();
-
- try
- {
- _observer.OnError(error);
- }
- finally
- {
- Interlocked.Exchange(ref _state, DONE);
- }
- }
-
- public void OnCompleted()
- {
- CheckAccess();
-
- try
- {
- _observer.OnCompleted();
- }
- finally
- {
- Interlocked.Exchange(ref _state, DONE);
- }
- }
-
- private void CheckAccess()
- {
- switch (Interlocked.CompareExchange(ref _state, BUSY, IDLE))
- {
- case BUSY:
- throw new InvalidOperationException(Strings_Core.REENTRANCY_DETECTED);
- case DONE:
- throw new InvalidOperationException(Strings_Core.OBSERVER_TERMINATED);
- }
- }
- }
-}