Exemplo n.º 1
0
            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);
            }
Exemplo n.º 2
0
            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"));
            }
Exemplo n.º 3
0
Arquivo: IVar.cs Projeto: mavnn/Hopac
            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);
            }