public AsyncCommandCollection Dequeue() { var result = _commands.Dequeue(); if (_commands.Count == 0) { _last = null; } return(result); }
/// <summary> /// Terminates chains execution /// Note, terminating task commands not supported, so if this command has started, it will comlete any way /// In case chain terminating next commands will not start /// </summary> public override void Terminate() { if (_actualCommand != null) { _actualCommand.Terminate(); _actualCommand = null; } ; while (_commands.Count != 0) { var command = _commands.Dequeue(); command.ReportChainTerminated(); } }
/// <summary> /// Invokes execution queue /// </summary> internal AsyncCommandResult UpdateChain() { while (true) { if (_actualCommand == null) { isComplete = _commands.Count == 0; if (isComplete) { return(AsyncCommandResult.Ok); } _actualCommand = _commands.Dequeue(); AsyncCommandResult startResult = _actualCommand.Start(); if (startResult != AsyncCommandResult.Ok) { return(startResult); } } if (_actualCommand == null) { // chain was terminated return(AsyncCommandResult.Ok); } _actualCommand.CheckNullStates(); AsyncCommandResult updateResult = _actualCommand.UpdateStates(); _actualCommand.CheckAndReportComplete(); if (updateResult != AsyncCommandResult.Ok) { return(updateResult); } if (_actualCommand.isComplete) { _actualCommand = null; } else { break; } } return(AsyncCommandResult.Ok); }
public void Clear() { _commands.Clear(); _last = null; }
public void Enqueue(AsyncCommandCollection command) { _last = command; _commands.Enqueue(command); }