private List <Action> TryDequeue() { if (_actions.Count > 0) { Lists.Swap(ref _actions, ref _toPass); _actions.Clear(); return(_toPass); } return(null); }
private List <Action> DequeueAll() { Wait(); lock (_syncRoot) { if (Actions.Count == 0) { return(Queue.Empty); } Lists.Swap(ref Actions, ref ToPass); Actions.Clear(); return(ToPass); } }
public List <Action> Drain() { lock (_lock) { if (ReadyToDequeue()) { Lists.Swap(ref _actions, ref _toPass); _actions.Clear(); return(_toPass); } return(null); } }
private List <Action> ClearActions() { lock (_lock) { if (_queue.Count == 0) { _flushPending = false; return(Queue.Empty); } Lists.Swap(ref _queue, ref _toPass); _queue.Clear(); return(_toPass); } }
public List <Action> Drain() { lock (_lock) { if (ReadyToDequeue()) { Lists.Swap(ref _actions, ref _toPass); _actions.Clear(); Monitor.PulseAll(_lock); return(_toPass); } return(Queue.Empty); } }
private List <Action> DequeueAll() { bool lockTaken = false; try { _lock.Enter(ref lockTaken); if (_actions.Count == 0) { return(Queue.Empty); } Lists.Swap(ref _actions, ref _toPass); _actions.Clear(); return(_toPass); } finally { if (lockTaken) { _lock.Exit(); } } }