comparison Implab/AbstractEvent.cs @ 240:fa6cbf4d8841 v3

refactoring, moving to dotnercore, simplifying promises
author cin
date Tue, 23 Jan 2018 19:39:21 +0300
parents d6fe09f5592c
children cbe10ac0731e
comparison
equal deleted inserted replaced
239:eedf4d834e67 240:fa6cbf4d8841
2 using Implab.Parallels; 2 using Implab.Parallels;
3 using System.Threading; 3 using System.Threading;
4 using System.Reflection; 4 using System.Reflection;
5 5
6 namespace Implab { 6 namespace Implab {
7 public abstract class AbstractEvent<THandler> : ICancellationToken, ICancellable { 7 public abstract class AbstractEvent<THandler> : ICancellable {
8 8
9 const int UNRESOLVED_SATE = 0; 9 const int UNRESOLVED_SATE = 0;
10 const int TRANSITIONAL_STATE = 1; 10 const int TRANSITIONAL_STATE = 1;
11 protected const int SUCCEEDED_STATE = 2; 11 protected const int SUCCEEDED_STATE = 2;
12 protected const int REJECTED_STATE = 3; 12 protected const int REJECTED_STATE = 3;
28 int m_handlerPointer = -1; 28 int m_handlerPointer = -1;
29 int m_handlersCommited; 29 int m_handlersCommited;
30 30
31 int m_cancelRequest; 31 int m_cancelRequest;
32 Exception m_cancelationReason; 32 Exception m_cancelationReason;
33 SimpleAsyncQueue<Action<Exception>> m_cancelationHandlers;
34
35 33
36 #region state managment 34 #region state managment
37 bool BeginTransit() { 35 bool BeginTransit() {
38 return UNRESOLVED_SATE == Interlocked.CompareExchange(ref m_state, TRANSITIONAL_STATE, UNRESOLVED_SATE); 36 return UNRESOLVED_SATE == Interlocked.CompareExchange(ref m_state, TRANSITIONAL_STATE, UNRESOLVED_SATE);
39 } 37 }