| 107 | } |
| 108 | |
| 109 | void Consumer::Run() { |
| 110 | comm::RetCode ret; |
| 111 | |
| 112 | if (impl_->opt.log_func) { |
| 113 | comm::Logger::GetInstance()->SetLogFunc(impl_->opt.log_func); |
| 114 | } |
| 115 | |
| 116 | if (impl_->opt.config_factory_create_func) { |
| 117 | plugin::ConfigFactory::SetConfigFactoryCreateFunc(impl_->opt.config_factory_create_func); |
| 118 | } |
| 119 | |
| 120 | if (impl_->opt.break_point_factory_create_func) { |
| 121 | plugin::BreakPointFactory::SetBreakPointFactoryCreateFunc(impl_->opt.break_point_factory_create_func); |
| 122 | } |
| 123 | |
| 124 | if (comm::RetCode::RET_OK != (ret = config::GlobalConfig::GetThreadInstance()->GetTopicIDByTopicName(impl_->opt.topic, impl_->topic_id))) { |
| 125 | QLErr("GetTopicIDByTopicName ret %d topic %s", comm::as_integer(ret), impl_->opt.topic.c_str()); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | const int shm_key{impl_->opt.shm_key_base + impl_->topic_id}; |
| 130 | const string lock_path{impl_->opt.lock_path_base + to_string(impl_->topic_id)}; |
| 131 | |
| 132 | if (comm::RetCode::RET_OK != (ret = impl_->lock.Init(this, shm_key, lock_path, impl_->opt.nprocs))) { |
| 133 | QLErr("HeartBeatLock::Init ret %d", comm::as_integer(ret)); |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | if (comm::RetCode::RET_OK != (ret = impl_->freq.Init(impl_->topic_id, this))) { |
| 138 | QLErr("FreqMan::Init ret %d", comm::as_integer(ret)); |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | BeforeFork(); |
| 143 | |
| 144 | |
| 145 | QLInfo("INFO: run sync"); |
| 146 | impl_->lock.RunSync(); |
| 147 | |
| 148 | |
| 149 | QLInfo("INFO: run freqman"); |
| 150 | impl_->freq.Run(); |
| 151 | |
| 152 | QLInfo("INFO: procs %d", impl_->opt.nprocs); |
| 153 | ForkAndRun(impl_->opt.nprocs); |
| 154 | |
| 155 | QLErr("consumer stop"); |
| 156 | } |
| 157 | |
| 158 | int Consumer::GetTopicID() { |
| 159 | return impl_->topic_id; |
nothing calls this directly
no test coverage detected