| 37 | } |
| 38 | |
| 39 | bool RpcSchedule::DequeueRpc(RpcTask** rpc) { |
| 40 | MutexLock lock(&mutex_); |
| 41 | if (pending_task_count_ == 0) { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | TableList::iterator it = policy_->Pick(&table_list_); |
| 46 | CHECK(it != table_list_.end()); |
| 47 | |
| 48 | ScheduleEntity* entity = (ScheduleEntity*)it->second; |
| 49 | TaskQueue* task_queue = (TaskQueue*)entity->user_ptr; |
| 50 | CHECK_GT(task_queue->size(), 0U); |
| 51 | |
| 52 | *rpc = task_queue->front(); |
| 53 | task_queue->pop(); |
| 54 | |
| 55 | task_queue->pending_count--; |
| 56 | task_queue->running_count++; |
| 57 | pending_task_count_--; |
| 58 | running_task_count_++; |
| 59 | |
| 60 | if (task_queue->pending_count == 0) { |
| 61 | policy_->Disable(entity); |
| 62 | } |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | bool RpcSchedule::FinishRpc(const std::string& table_name) { |
| 67 | MutexLock lock(&mutex_); |
no test coverage detected