internal override void DoHandle(ref Worker wr, Exception e) { var tP = this.tP as Promise <T>; Spin: var state = tP.State; if (state != Running) { goto Spin; } if (Running != Interlocked.CompareExchange(ref tP.State, state - MakeLocked, state)) { goto Spin; } var readers = tP.Readers; tP.Readers = new Fail <T>(e); tP.State = HasExn; WaitQueue.FailReaders(readers, e, ref wr); var reader = this.reader; if (null == reader) { return; } wr.Handler = reader; reader.DoHandle(ref wr, e); }
internal override void DoJob(ref Worker wr, Cont <Unit> uK) { var tI = this.tI; Spin: var state = tI.State; if (state < Delayed) { goto Spin; } if (state != Interlocked.CompareExchange(ref tI.State, ~state, state)) { goto Spin; } if (state > Running) { goto IVarFull; } var readers = tI.Readers; var e = this.e; tI.Readers = new Fail <T>(e); tI.State = HasExn; WaitQueue.FailReaders(readers, e, ref wr); Work.Do(uK, ref wr); return; IVarFull: uK.DoHandle(ref wr, new Exception("IVar full")); }
internal override void DoJob(ref Worker wr, Cont <Unit> uK) { var tI = this.tI; Spin: var state = tI.State; if (state < Delayed) { goto Spin; } if (state > Running) { goto Done; } if (state != Interlocked.CompareExchange(ref tI.State, ~state, state)) { goto Spin; } var readers = tI.Readers; var e = this.e; tI.Readers = new Fail <T>(e); tI.State = HasExn; WaitQueue.FailReaders(readers, e, ref wr); Done: Work.Do(uK, ref wr); }