31 void enqueue(Action action) { _queue.push_back({ std::move(action),
nullptr, {} }); }
35 auto lookupKey = std::make_pair(owner, key);
37 auto it = indexMap_.find(lookupKey);
38 if (it != indexMap_.end()) {
40 it->second->execute = std::move(action);
43 _queue.push_back({ std::move(action), owner, key });
44 indexMap_[lookupKey] = --_queue.end();
50 while (!_queue.empty()) {
51 Command cmd = std::move(_queue.front());
56 indexMap_.erase({ cmd.
owner, cmd.
key });
61 }
catch (std::exception& e) {
67 static void clearGlobalQueue() { _global_queue =
nullptr; }
69 static void setGlobalQueue(
ActionQueue* queue) { _global_queue = queue; }
71 static ActionQueue* getGlobalQueue() {
return _global_queue; }
76 std::size_t operator()(
const std::pair<const ActionDispatcher*, ActionKey>& p)
const {
77 auto h1 = std::hash<const ActionDispatcher*>{}(p.first);
78 auto h2 = std::hash<ActionKey>{}(p.second);
79 return h1 ^ (h2 << 1);
83 std::deque<Command> _queue;
85 std::unordered_map<std::pair<const ActionDispatcher*, ActionKey>, std::deque<Command>::iterator, PairHash> indexMap_;
const ActionDispatcher * owner
Owner of the command used to identify replaceable actions. If owner == nullptr, this task is non-repl...
Definition Command.hpp:31