| 146 | } |
| 147 | |
| 148 | comm::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 | |
| 173 | comm::RetCode SyncCtrl::GetCursorID(const int sub_id, const int queue_id, |
| 174 | uint64_t &cursor_id, const bool is_prev) const { |
no test coverage detected