update task sleep logic

This commit is contained in:
MistEO
2021-07-20 23:17:26 +08:00
parent e589a7498c
commit 53a1297842
2 changed files with 18 additions and 3 deletions

View File

@@ -141,7 +141,12 @@ void Assistance::workingProc(Assistance* pThis)
DebugTraceInfo("***Matched***", matched_task, "Type:", static_cast<int>(task.type));
if (task.pre_delay > 0) {
DebugTrace("PreDelay", task.pre_delay);
std::this_thread::sleep_for(std::chrono::milliseconds(task.pre_delay));
// std::this_thread::sleep_for(std::chrono::milliseconds(task.pre_delay));
auto cv_ret = pThis->m_condvar.wait_for(lock, std::chrono::milliseconds(task.pre_delay),
[&]() -> bool { return !pThis->m_thread_running; });
if (cv_ret == true) {
continue;
}
}
if (task.max_times != INT_MAX) {
@@ -171,7 +176,12 @@ void Assistance::workingProc(Assistance* pThis)
++task.exec_times;
if (task.rear_delay > 0) {
DebugTrace("RearDelay", task.rear_delay);
std::this_thread::sleep_for(std::chrono::milliseconds(task.rear_delay));
// std::this_thread::sleep_for(std::chrono::milliseconds(task.rear_delay));
auto cv_ret = pThis->m_condvar.wait_for(lock, std::chrono::milliseconds(task.rear_delay),
[&]() -> bool { return !pThis->m_thread_running; });
if (cv_ret == true) {
continue;
}
}
pThis->m_next_tasks = Configer::m_tasks[matched_task].next;
}
@@ -189,7 +199,9 @@ void Assistance::workingProc(Assistance* pThis)
}
DebugTrace("Next:", nexts_str);
}
pThis->m_condvar.wait_for(lock, std::chrono::milliseconds(Configer::m_options.delayFixedTime));
pThis->m_condvar.wait_for(lock,
std::chrono::milliseconds(Configer::m_options.delayFixedTime),
[&]() -> bool { return !pThis->m_thread_running; });
}
else {
pThis->m_condvar.wait(lock);

View File

@@ -93,6 +93,7 @@ MuMu是个奇葩它的所有的窗口句柄均不响应SendMessage鼠标消
- [x] 支持自动勾选代理指挥
- [x] 支持刷指定次数
- [x] 自动吃石头(根据设置,指定数量)
- [ ] 指定刷XX个某材料
- [ ] 支持凌晨4点更新数据
- [ ] 结束界面自动截图,可用于上传企鹅物流
- [ ] 持续监视理智,一有就自动刷掉
@@ -105,6 +106,8 @@ MuMu是个奇葩它的所有的窗口句柄均不响应SendMessage鼠标消
- [x] 更换算法为模板匹配找图,而不是当前的区域相似度对比
- [x] 优化算法效率,添加缓存功能
- [x] 优化任务队列,减少不必要的计算
- [ ] 掉落材料计数
- [ ] 窗口分辨率自适应
- [ ] 进一步优化任务队列效率
- [x] 其他
- [x] 尝试减小程序体积