MCPcopy Create free account
hub / github.com/Tencent/phxqueue / GetCursorID

Method GetCursorID

phxqueue/store/syncctrl.cpp:173–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173comm::RetCode SyncCtrl::GetCursorID(const int sub_id, const int queue_id,
174 uint64_t &cursor_id, const bool is_prev) const {
175 cursor_id = -1;
176
177 auto opt = impl_->store->GetStoreOption();
178
179 if (!sub_id || sub_id > opt->nsub || queue_id >= opt->nqueue)
180 return comm::RetCode::RET_ERR_ARG;
181
182 size_t idx;
183 GetIdx(opt->nsub, sub_id, queue_id, idx);
184
185 lock_guard<mutex> lock_guard(impl_->locks[idx]);
186
187 auto &&item(impl_->buf[idx]);
188
189 if (is_prev) {
190 if (item.prev_magic != SYNCCTRL_MAGIC) return comm::RetCode::RET_ERR_CURSOR_NOT_FOUND;
191 cursor_id = item.prev_cursor_id;
192 } else {
193 if (item.next_magic != SYNCCTRL_MAGIC) return comm::RetCode::RET_ERR_CURSOR_NOT_FOUND;
194 cursor_id = item.next_cursor_id;
195 }
196
197 return comm::RetCode::RET_OK;
198}
199
200void SyncCtrl::ClearSyncCtrl() {
201 if (!impl_->buf) {

Callers 6

NeedSkipAddMethod · 0.45
GetMethod · 0.45
MakeCheckPointMethod · 0.45
SyncCursorIDMethod · 0.45
ReplayMethod · 0.45
ReportBacklogMethod · 0.45

Calls 2

GetIdxFunction · 0.85
GetStoreOptionMethod · 0.80

Tested by

no test coverage detected