public void Resume() { if (State == MicroThreadState.Blocking) { State = MicroThreadState.Ready; } }
public MicroThread(Loop loop, Action callback) { Loop = loop; State = MicroThreadState.NotStarted; Loop.GetMicroThreadCollection().Add(this); cb = callback; }
public void Start() { switch (State) { case MicroThreadState.NotStarted: State = MicroThreadState.Ready; break; default: break; } }
internal void Yield(MicroThreadState newState) { if (State == MicroThreadState.Running) { State = newState; if (Continuation.Store(0) == 0) { Loop.GetMicroThreadCollection().Next(); } } }
public void Start() { if (m_state != MicroThreadState.Unstarted) { throw new Exception("Thread has already been started"); } m_continuation = new Continuation(); m_state = MicroThreadState.Starting; Scheduler.Add(this); }
internal void Run() { State = MicroThreadState.Running; if (Continuation == null) { Continuation = new Continuation(); Continuation.Mark(); cb(); State = MicroThreadState.Done; Loop.GetMicroThreadCollection().Next(); } else { Continuation.Restore(1); } }
public void Start() { if(m_state != MicroThreadState.Unstarted) { throw new Exception("Thread has already been started"); } m_continuation = new Continuation(); m_state = MicroThreadState.Starting; Scheduler.Add(this); }