Ejemplo n.º 1
0
 public void Dispose()
 {
     if (this.context != null)
     {
         this.context.Dispose();
         this.context = null;
     }
 }
Ejemplo n.º 2
0
 public void yield(context to)
 {
   if(to == this) return;
   context.lck(this, () => {
       to.release();
       do_block(this);
     });
 }
Ejemplo n.º 3
0
    public void call(context c)
    {
      Debug.WriteLine("[" + this.get_id() + "] call");
      context.lck(this, () => {
          do_release(this);

          Monitor.Enter(c);
          c.state = State.BLOCKED;
        });

      do { Monitor.Wait(c); } while(c.state == State.BLOCKED);
      Monitor.Exit(c);
    }
Ejemplo n.º 4
0
        public coroutine(Action worker)
        {
            this.id         = -2;
            this.yield      = null;
            this.port       = null;
            this.finished   = false;
            this.released   = false;
            this.skip_block = false;

            this.context = new context((yield) => {
                this.id    = context.get_id();
                this.yield = yield;
                worker();
            });
        }
Ejemplo n.º 5
0
 public coroutine()
 {
     this.id      = -1;
     this.context = new context(false);
     this.yield   = null;
 }