本文共 3933 字,大约阅读时间需要 13 分钟。
ExecuteOneCommand函数:
58 void ActionManager::ExecuteOneCommand() { 59 // Loop through the event queue until we have an action to execute 60 while (current_executing_actions_.empty() && !event_queue_.empty()) { 61 for (const auto& action : actions_) { 62 if (std::visit([&action](const auto& event) { return action->CheckEvent(event); }, 63 event_queue_.front())) { 64 current_executing_actions_.emplace(action.get()); 65 } 66 } 67 event_queue_.pop(); 68 } 69 70 if (current_executing_actions_.empty()) { 71 return; 72 } 73 74 auto action = current_executing_actions_.front(); 75 76 if (current_command_ == 0) { 77 std::string trigger_name = action->BuildTriggersString(); 78 LOG(INFO) << "processing action (" << trigger_name << ") from (" << action->filename() 79 << ":" << action->line() << ")"; 80 } 81 82 action->ExecuteOneCommand(current_command_); 83 84 // If this was the last command in the current action, then remove 85 // the action from the executing list. 86 // If this action was oneshot, then also remove it from actions_. 87 ++current_command_; 88 if (current_command_ == action->NumCommands()) { 89 current_executing_actions_.pop(); 90 current_command_ = 0; 91 if (action->oneshot()) { 92 auto eraser = [&action](std::unique_ptr& a) { return a.get() == action; }; 93 actions_.erase(std::remove_if(actions_.begin(), actions_.end(), eraser)); 94 } 95 } 96 }
通过打印信息知道:
init: 7 early-initinit: 7 initinit: 7 init: 7 load_persist_props_actioninit: 7 firmware_mounts_completeinit: 7 late-init可以知道actions_中包含event_name为early-init,init,load_persist_props_action,firmware_mounts_complete和late-init的action。 从打印中,可以看出init 的action中的命令没有执行完毕。
转载地址:http://eafab.baihongyu.com/