Files
BlindCane/Core/App/Helper/task_helper.hpp
chauyin 2ce600dc4d
All checks were successful
Build and Upload Artifact / build and upload-artifact (push) Successful in 20m4s
删除多个类和结构体的拷贝构造函数和赋值运算符,确保不可复制性
2025-05-21 18:55:14 +08:00

19 lines
482 B
C++

#pragma once
#include "stm32h5xx_hal.h"
#include <cstdint>
#include <stdexcept>
namespace TaskHelper {
template <typename Func>
static void WaitFor(Func func, uint32_t timeoutMilliseconds) {
auto start = HAL_GetTick();
while (!func()) {
uint32_t now = HAL_GetTick();
if ((now - start) > timeoutMilliseconds) {
throw std::runtime_error("Operation timed out");
}
}
}
}; // namespace TaskHelper