|
@@ -1,3 +1,4 @@
|
|
|
|
+using System.Threading;
|
|
using Jint.Native.Object;
|
|
using Jint.Native.Object;
|
|
using Jint.Native.Promise;
|
|
using Jint.Native.Promise;
|
|
using Jint.Runtime;
|
|
using Jint.Runtime;
|
|
@@ -12,7 +13,7 @@ internal sealed class JsPromise : ObjectInstance
|
|
|
|
|
|
// valid only in settled state (Fulfilled or Rejected)
|
|
// valid only in settled state (Fulfilled or Rejected)
|
|
internal JsValue Value { get; private set; } = null!;
|
|
internal JsValue Value { get; private set; } = null!;
|
|
- internal TaskCompletionSource<JsPromise> TaskCompletionSource { get; }= new();
|
|
|
|
|
|
+ internal ManualResetEventSlim CompletedEvent { get; } = new();
|
|
|
|
|
|
internal List<PromiseReaction> PromiseRejectReactions = new();
|
|
internal List<PromiseReaction> PromiseRejectReactions = new();
|
|
internal List<PromiseReaction> PromiseFulfillReactions = new();
|
|
internal List<PromiseReaction> PromiseFulfillReactions = new();
|
|
@@ -127,7 +128,7 @@ internal sealed class JsPromise : ObjectInstance
|
|
var reactions = PromiseRejectReactions;
|
|
var reactions = PromiseRejectReactions;
|
|
PromiseRejectReactions = new List<PromiseReaction>();
|
|
PromiseRejectReactions = new List<PromiseReaction>();
|
|
PromiseFulfillReactions.Clear();
|
|
PromiseFulfillReactions.Clear();
|
|
- TaskCompletionSource.SetCanceled();
|
|
|
|
|
|
+ CompletedEvent.Set();
|
|
|
|
|
|
// Note that this part is skipped because there is no tracking yet
|
|
// Note that this part is skipped because there is no tracking yet
|
|
// 7. If promise.[[PromiseIsHandled]] is false, perform HostPromiseRejectionTracker(promise, "reject").
|
|
// 7. If promise.[[PromiseIsHandled]] is false, perform HostPromiseRejectionTracker(promise, "reject").
|
|
@@ -147,7 +148,7 @@ internal sealed class JsPromise : ObjectInstance
|
|
var reactions = PromiseFulfillReactions;
|
|
var reactions = PromiseFulfillReactions;
|
|
PromiseFulfillReactions = new List<PromiseReaction>();
|
|
PromiseFulfillReactions = new List<PromiseReaction>();
|
|
PromiseRejectReactions.Clear();
|
|
PromiseRejectReactions.Clear();
|
|
- TaskCompletionSource.SetResult(this);
|
|
|
|
|
|
+ CompletedEvent.Set();
|
|
|
|
|
|
return PromiseOperations.TriggerPromiseReactions(_engine, reactions, result);
|
|
return PromiseOperations.TriggerPromiseReactions(_engine, reactions, result);
|
|
}
|
|
}
|