40 InitGroup(group_name);
43void ClassicContext::InitGroup(
const std::string& group_name) {
46 mtx_wrapper_ = &
mtx_wq_[group_name];
49 current_grp = group_name;
57 for (
int i = MAX_PRIO - 1; i >= 0; --i) {
59 for (
auto& cr : multi_pri_rq_->at(i)) {
64 if (cr->UpdateState() == RoutineState::READY) {
76 std::unique_lock<std::mutex> lk(mtx_wrapper_->
Mutex());
77 cw_->
Cv().wait_for(lk, std::chrono::milliseconds(1000),
86 mtx_wrapper_->
Mutex().lock();
87 notify_grp_[current_grp] = std::numeric_limits<unsigned char>::max();
88 mtx_wrapper_->
Mutex().unlock();
89 cw_->
Cv().notify_all();
93 (&
mtx_wq_[group_name])->Mutex().lock();
95 (&
mtx_wq_[group_name])->Mutex().unlock();
96 cv_wq_[group_name].Cv().notify_one();
100 auto grp = cr->group_name();
101 auto prio = cr->priority();
102 auto crid = cr->id();
105 for (
auto it = croutines.begin(); it != croutines.end(); ++it) {
106 if ((*it)->id() == crid) {
109 while (!cr->Acquire()) {
110 std::this_thread::sleep_for(std::chrono::microseconds(1));
111 AINFO_EVERY(1000) <<
"waiting for task " << cr->name() <<
" completion";
static void Notify(const std::string &group_name)
static RQ_LOCK_GROUP rq_locks_
static CR_GROUP cr_group_
static GRP_WQ_MUTEX mtx_wq_
static bool RemoveCRoutine(const std::shared_ptr< CRoutine > &cr)
std::shared_ptr< CRoutine > NextRoutine() override
static NOTIFY_GRP notify_grp_
std::condition_variable & Cv()
std::atomic< bool > stop_
#define DEFAULT_GROUP_NAME
#define cyber_unlikely(x)
#define AINFO_EVERY(freq)
std::unordered_map< std::string, MutexWrapper > GRP_WQ_MUTEX
std::unordered_map< std::string, CvWrapper > GRP_WQ_CV
std::unordered_map< std::string, LOCK_QUEUE > RQ_LOCK_GROUP
std::unordered_map< std::string, MULTI_PRIO_QUEUE > CR_GROUP
std::unordered_map< std::string, int > NOTIFY_GRP