public void next_dispatch(Action action) { if (running_in_this_thread()) { _readyQueue.AddFirst(action); } else { MsgQueueNode <Action> newNode = new MsgQueueNode <Action>(action); Monitor.Enter(this); if (_locked) { _waitQueue.AddFirst(newNode); Monitor.Exit(this); } else { _locked = true; _readyQueue.AddFirst(newNode); Monitor.Exit(this); next_a_round(); } } }
public void next_dispatch(Action action) { if (running_in_this_thread()) { _readyQueue.AddFirst(action); } else { MsgQueueNode <Action> newNode = new MsgQueueNode <Action>(action); _mutex.enter(); if (_locked) { _waitQueue.AddFirst(newNode); _mutex.exit(); } else { _locked = true; _readyQueue.AddFirst(newNode); _mutex.exit(); run_task(); } } }