lib/orchestrator/device/processor.rb in orchestrator-1.0.2 vs lib/orchestrator/device/processor.rb in orchestrator-1.0.3
- old
+ new
@@ -32,10 +32,11 @@
force_disconnect: false # Mainly for use with make and break
# Other options include:
# * emit callback to occur once command complete (may be discarded if a named command)
# * on_receive (alternative to received function)
+ # * clear_queue (clear further commands once this has run)
}
CONFIG_DEFAULTS = {
tokenize: false, # If replaced with a callback can define custom tokenizers
size_limit: 524288, # 512kb buffer max
@@ -423,9 +424,15 @@
else
# resole the send promise early as we are not waiting for the response
command[:defer].resolve(:no_wait)
call_emit command # the command has been sent
end
+
+ # Useful for emergency stops etc
+ if command[:clear_queue]
+ @queue.cancel_all("Command #{command[:name]} cleared the queue")
+ end
+
nil # ensure promise chain is not propagated
end
def clear_timers
@timeout.cancel if @timeout