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

Method UpdateCursorID

phxqueue/store/syncctrl.cpp:148–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148comm::RetCode SyncCtrl::UpdateCursorID(const int sub_id, const int queue_id,
149 const uint64_t cursor_id, const bool is_prev) {
150 auto opt = impl_->store->GetStoreOption();
151
152 if (!sub_id || sub_id > opt->nsub || queue_id >= opt->nqueue)
153 return comm::RetCode::RET_ERR_ARG;
154
155 size_t idx;
156 GetIdx(opt->nsub, sub_id, queue_id, idx);
157
158 lock_guard<mutex> lock_guard(impl_->locks[idx]);
159
160 auto &&item = impl_->buf[idx];
161
162 if (is_prev) {
163 if (item.prev_magic != SYNCCTRL_MAGIC) item.prev_magic = SYNCCTRL_MAGIC;
164 item.prev_cursor_id = cursor_id;
165 } else {
166 if (item.next_magic != SYNCCTRL_MAGIC) item.next_magic = SYNCCTRL_MAGIC;
167 item.next_cursor_id = cursor_id;
168 }
169
170 return comm::RetCode::RET_OK;
171}
172
173comm::RetCode SyncCtrl::GetCursorID(const int sub_id, const int queue_id,
174 uint64_t &cursor_id, const bool is_prev) const {

Callers 2

GetMethod · 0.80
ReplayMethod · 0.80

Calls 2

GetIdxFunction · 0.85
GetStoreOptionMethod · 0.80

Tested by

no test coverage detected