mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 01:59:33 +08:00
1>D:\Code\MeoAssistantArknights\src\MaaCore\Task\AbstractTask.cpp(25,1): error C2220: 以下警告被视为错误 1>D:\Code\MeoAssistantArknights\src\MaaCore\Task\AbstractTask.cpp(24,17): warning C4589: 抽象类“asst::AbstractTask”的构造函数忽略虚拟基类“asst::InstHelper”的初始化设定值 1>D:\Code\MeoAssistantArknights\src\MaaCore\Task\AbstractTask.cpp(24,17): message : 虚拟基类仅由最底层派生类型进行初始化
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#include "InstHelper.h"
|
|
|
|
#include "Assistant.h"
|
|
#include "Utils/Logger.hpp"
|
|
|
|
asst::InstHelper::InstHelper(asst::Assistant* inst) : m_inst(inst) {}
|
|
|
|
std::shared_ptr<asst::Controller> asst::InstHelper::ctrler() const
|
|
{
|
|
return m_inst ? m_inst->ctrler() : nullptr;
|
|
}
|
|
std::shared_ptr<asst::Status> asst::InstHelper::status() const
|
|
{
|
|
return m_inst ? m_inst->status() : nullptr;
|
|
}
|
|
bool asst::InstHelper::need_exit() const
|
|
{
|
|
return m_inst ? m_inst->need_exit() : false;
|
|
}
|
|
|
|
bool asst::InstHelper::sleep(unsigned millisecond) const
|
|
{
|
|
if (need_exit()) {
|
|
return false;
|
|
}
|
|
if (millisecond == 0) {
|
|
std::this_thread::yield();
|
|
return true;
|
|
}
|
|
auto start = std::chrono::steady_clock::now();
|
|
Log.trace("ready to sleep", millisecond);
|
|
auto millisecond_ms = std::chrono::milliseconds(millisecond);
|
|
auto interval = millisecond_ms / 5;
|
|
|
|
while (!need_exit()) {
|
|
std::this_thread::sleep_for(interval);
|
|
if (std::chrono::steady_clock::now() - start > millisecond_ms) {
|
|
break;
|
|
}
|
|
}
|
|
Log.trace("end of sleep", millisecond);
|
|
|
|
return !need_exit();
|
|
}
|