#if defined _WIN32 || defined __WINDOWS__ #include <windows.h> #define MSleep(MilliSec) Sleep(MilliSec) #else #include <unistd.h> #define MSleep(MilliSec) usleep(1000 * MilliSec) #endif #include <thread> #include <functional> #include <memory> #include <mutex> #include <condition_variable> #include <chrono> namespace CPCE { enum RunStatus { STOPED = 0, START_SYN, START_ASYN }; class MyTimer { public: MyTimer():m_status(RunStatus::STOPED),m_threadPtr(NULL),m_sleepMilliSec(-1){} ~MyTimer() { if (m_threadPtr != NULL) {
C++ 实现同步异步定时器
最新推荐文章于 2024-08-28 15:30:04 发布