feat fix miss std::atomic_uint64_t
Some checks failed
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (push) Waiting to run
linux-x64-gcc / linux-gcc (push) Failing after 49s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Failing after 59s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Failing after 1m19s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 1m0s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Failing after 1m34s
Some checks failed
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Waiting to run
linux-mips64-gcc / linux-gcc-mips64el (push) Waiting to run
linux-x64-gcc / linux-gcc (push) Failing after 49s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Failing after 59s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Failing after 1m19s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Failing after 1m0s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Failing after 1m34s
This commit is contained in:
parent
90e10881d3
commit
8e35843d04
@ -18,16 +18,24 @@ TimeNowInMicroSeconds()
|
||||
return tv.tv_sec * 1000000ULL + tv.tv_usec;
|
||||
}
|
||||
|
||||
std::atomic_uint64_t Timer::next_timer_id_(1);
|
||||
std::atomic<uint64_t> Timer::next_timer_id_(0);
|
||||
|
||||
Timer::Timer(uint64_t when, uint64_t interval)
|
||||
: timer_id_(next_timer_id_.fetch_add(1)),
|
||||
: timer_id_(NextTimerId()),
|
||||
when_(when),
|
||||
interval_(interval),
|
||||
auto_reset_(interval_ > 0),
|
||||
expire_callback_()
|
||||
{}
|
||||
|
||||
uint64_t
|
||||
Timer::NextTimerId()
|
||||
{
|
||||
uint64_t id = 0;
|
||||
while (id == 0) { id = next_timer_id_.fetch_add(1); }
|
||||
return id;
|
||||
}
|
||||
|
||||
TimerManager::TimerManager()
|
||||
: stopped_(false),
|
||||
thread_(std::bind(&TimerManager::Loop, this), "timer_manager_thread"),
|
||||
|
@ -16,6 +16,7 @@ using TimerId = uint64_t;
|
||||
|
||||
class Timer {
|
||||
public:
|
||||
const uint64_t INVALID_TIMER_ID = 0;
|
||||
using ExpireCallback = std::function<void()>;
|
||||
Timer(uint64_t when, uint64_t intarval);
|
||||
// void Start();
|
||||
@ -29,6 +30,7 @@ public:
|
||||
bool operator == (const Timer& rhs) const { return timer_id_ == rhs.timer_id_; }
|
||||
|
||||
private:
|
||||
static uint64_t NextTimerId();
|
||||
const TimerId timer_id_;
|
||||
// micro seconds
|
||||
uint64_t when_;
|
||||
@ -36,7 +38,7 @@ private:
|
||||
uint64_t interval_;
|
||||
bool auto_reset_;
|
||||
ExpireCallback expire_callback_;
|
||||
static std::atomic_uint64_t next_timer_id_;
|
||||
static std::atomic<uint64_t> next_timer_id_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user