void RepeatedTimerTask::run_once_now() { std::unique_lock<raft_mutex_t> lck(_mutex); if (bthread_timer_del(_timer) == 0) { lck.unlock(); on_timedout(this); } }
void Stream::StopIdleTimer() { if (_options.idle_timeout_ms < 0) { return; } if (_idle_timer != 0) { bthread_timer_del(_idle_timer); } }
void RepeatedTimerTask::reset() { std::unique_lock<raft_mutex_t> lck(_mutex); BRAFT_RETURN_IF(_stopped); CHECK(_running); const int rc = bthread_timer_del(_timer); if (rc == 0) { return schedule(lck); } // else on_timedout would invoke schdule }
void RepeatedTimerTask::stop() { BAIDU_SCOPED_LOCK(_mutex); BRAFT_RETURN_IF(_stopped); _stopped = true; CHECK(_running); const int rc = bthread_timer_del(_timer); if (rc == 0) { _running = false; return; } }
void DownSpeed::Clear() { #ifdef CszTest Csz::LI("[%s->%s->%d]",__FILE__,__func__,__LINE__); #endif auto code= bthread_timer_del(id); if (code!= 0) { Csz::ErrMsg("[%s->%s->%d]->failed,calculate speed still running or einval,code=%d",__FILE__,__func__,__LINE__,code); } pthread_rwlock_destroy(&lock); queue.clear(); return ; }
void RemoteFileCopier::Session::cancel() { BAIDU_SCOPED_LOCK(_mutex); if (_finished) { return; } brpc::StartCancel(_rpc_call); if (bthread_timer_del(_timer) == 0) { // Release reference of the timer task Release(); } if (_st.ok()) { _st.set_error(ECANCELED, "%s", berror(ECANCELED)); } on_finished(); }
void RepeatedTimerTask::destroy() { std::unique_lock<raft_mutex_t> lck(_mutex); BRAFT_RETURN_IF(_destroyed); _destroyed = true; if (!_running) { CHECK(_stopped); lck.unlock(); on_destroy(); return; } BRAFT_RETURN_IF(_stopped); _stopped = true; const int rc = bthread_timer_del(_timer); if (rc == 0) { _running = false; lck.unlock(); on_destroy(); return; } CHECK(_running); }
int Stream::TriggerOnWritable(bthread_id_t id, void *data, int error_code) { WritableMeta *wm = (WritableMeta*)data; if (wm->has_timer) { bthread_timer_del(wm->timer); } wm->error_code = error_code; if (wm->new_thread) { const bthread_attr_t* attr = FLAGS_usercode_in_pthread ? &BTHREAD_ATTR_PTHREAD : &BTHREAD_ATTR_NORMAL; bthread_t tid; if (bthread_start_background(&tid, attr, RunOnWritable, wm) != 0) { LOG(FATAL) << "Fail to start bthread" << berror(); RunOnWritable(wm); } } else { RunOnWritable(wm); } return bthread_id_unlock_and_destroy(id); }