| 171 | } |
| 172 | |
| 173 | comm::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 | |
| 200 | void SyncCtrl::ClearSyncCtrl() { |
| 201 | if (!impl_->buf) { |
no test coverage detected