feat update
All checks were successful
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m4s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m10s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m21s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m28s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m27s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m29s
linux-x64-gcc / linux-gcc (push) Successful in 1m36s
All checks were successful
rpcrypto-build / build (Debug, hisiv510.toolchain.cmake) (push) Successful in 1m4s
rpcrypto-build / build (Release, himix200.toolchain.cmake) (push) Successful in 1m10s
rpcrypto-build / build (Release, hisiv510.toolchain.cmake) (push) Successful in 1m21s
rpcrypto-build / build (Debug, himix200.toolchain.cmake) (push) Successful in 1m28s
linux-hisiv500-gcc / linux-gcc-hisiv500 (push) Successful in 1m27s
linux-mips64-gcc / linux-gcc-mips64el (push) Successful in 1m29s
linux-x64-gcc / linux-gcc (push) Successful in 1m36s
This commit is contained in:
parent
2e0e00af0c
commit
47b64af7a8
@ -53,31 +53,39 @@ TimerManager::AddTimerImpl(const Timer::ExpireCallback &cb,
|
||||
uint64_t run_after_ms,
|
||||
uint64_t interval)
|
||||
{
|
||||
MutexGuard guard(timer_inserting_set_lock_);
|
||||
auto *timer = new Timer(TimeNowInMicroSeconds() + run_after_ms * 1000,
|
||||
interval * 1000);
|
||||
timer->on_expire() = cb;
|
||||
if (!timer_inserting_set_.insert({timer->when(), timer}).second) {
|
||||
ULOG_ERROR("system.timer_manager",
|
||||
"Add timer failed, already exists timer_id={}", timer->id());
|
||||
delete timer;
|
||||
return 0;
|
||||
Timer *timer = nullptr;
|
||||
{
|
||||
MutexGuard guard(timer_inserting_set_lock_);
|
||||
timer = new Timer(TimeNowInMicroSeconds() + run_after_ms * 1000,
|
||||
interval * 1000);
|
||||
timer->on_expire() = cb;
|
||||
if (!timer_inserting_set_.insert({timer->when(), timer}).second) {
|
||||
ULOG_ERROR("system.timer_manager",
|
||||
"Add timer failed, already exists timer_id={}",
|
||||
timer->id());
|
||||
delete timer;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
timers_lock_.Lock();
|
||||
timers_cond_.NotifyAll();
|
||||
timers_lock_.Unlock();
|
||||
{
|
||||
MutexGuard timers_guard(timers_lock_);
|
||||
timers_cond_.NotifyAll();
|
||||
}
|
||||
return timer->id();
|
||||
}
|
||||
|
||||
void
|
||||
TimerManager::CancelTimerImpl(TimerId timer_id)
|
||||
{
|
||||
MutexGuard guard(timer_canceling_set_lock_);
|
||||
timer_canceling_set_.insert(timer_id);
|
||||
timers_lock_.Lock();
|
||||
timers_cond_.NotifyAll();
|
||||
timers_lock_.Unlock();
|
||||
{
|
||||
MutexGuard guard(timer_canceling_set_lock_);
|
||||
timer_canceling_set_.insert(timer_id);
|
||||
}
|
||||
{
|
||||
MutexGuard timers_guard(timers_lock_);
|
||||
timers_cond_.NotifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user