public void Dispose() { if (this.context != null) { this.context.Dispose(); this.context = null; } }
public void yield(context to) { if(to == this) return; context.lck(this, () => { to.release(); do_block(this); }); }
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); }
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(); }); }
public coroutine() { this.id = -1; this.context = new context(false); this.yield = null; }