# HG changeset patch
# User cin
# Date 1425481539 -10800
# Node ID 16f926ee499d91fae9e74e4799b33bc37a8c4086
# Parent 2100965eb97f5c92f8731632172780f340e26302
DRAFT: refactoring, adding cancelation token
diff -r 2100965eb97f -r 16f926ee499d Implab/AbstractPromise.cs
--- a/Implab/AbstractPromise.cs Wed Mar 04 03:10:38 2015 +0300
+++ b/Implab/AbstractPromise.cs Wed Mar 04 18:05:39 2015 +0300
@@ -286,18 +286,6 @@
#endregion
- #region ICancellable implementation
-
- public void Cancel() {
- SetCancelled(null);
- }
-
- public void Cancel(Exception reason) {
- SetCancelled(reason);
- }
-
- #endregion
-
public Exception Error {
get {
return m_error;
diff -r 2100965eb97f -r 16f926ee499d Implab/ICancelationToken.cs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Implab/ICancelationToken.cs Wed Mar 04 18:05:39 2015 +0300
@@ -0,0 +1,36 @@
+using System;
+
+namespace Implab {
+ public interface ICancelationToken {
+ ///
+ /// Indicates wherther the cancellation was requested.
+ ///
+ bool IsCancelRequested { get ; }
+
+ ///
+ /// The reason why the operation should be cancelled.
+ ///
+ Exception CancelReason { get ; }
+
+ ///
+ /// Accepts if requested.
+ ///
+ /// true, if if requested was accepted, false otherwise.
+ bool AcceptIfRequested();
+
+ ///
+ /// Sets the token to cancelled state.
+ ///
+ /// The reason why the operation was cancelled.
+ void SetCancelled(Exception reason);
+
+ ///
+ /// Adds the listener for the cancellation request, is the cancellation was requested the
+ /// is executed immediatelly.
+ ///
+ /// The handler which will be executed if the cancel occurs.
+ void CancellationRequested(Action handler);
+
+ }
+}
+
diff -r 2100965eb97f -r 16f926ee499d Implab/IDeferred.cs
--- a/Implab/IDeferred.cs Wed Mar 04 03:10:38 2015 +0300
+++ b/Implab/IDeferred.cs Wed Mar 04 18:05:39 2015 +0300
@@ -4,7 +4,7 @@
///
/// Deferred result, usually used by asynchronous services as the service part of the promise.
///
- public interface IDeferred : ICancellable {
+ public interface IDeferred : ICancelationToken {
void Resolve();
diff -r 2100965eb97f -r 16f926ee499d Implab/IDeferredT.cs
--- a/Implab/IDeferredT.cs Wed Mar 04 03:10:38 2015 +0300
+++ b/Implab/IDeferredT.cs Wed Mar 04 18:05:39 2015 +0300
@@ -1,7 +1,7 @@
using System;
namespace Implab {
- public interface IDeferred : ICancellable {
+ public interface IDeferred : ICancelationToken {
void Resolve(T value);
void Reject(Exception error);
diff -r 2100965eb97f -r 16f926ee499d Implab/Implab.csproj
--- a/Implab/Implab.csproj Wed Mar 04 03:10:38 2015 +0300
+++ b/Implab/Implab.csproj Wed Mar 04 18:05:39 2015 +0300
@@ -7,6 +7,8 @@
Library
Implab
Implab
+ 8.0.30703
+ 2.0
true
@@ -156,6 +158,7 @@
+