| 173 | } |
| 174 | |
| 175 | void BinManager::removeOldestBin() { |
| 176 | std::lock_guard < std::mutex > lock(mutex_); |
| 177 | uint64_t olddate = ULLONG_MAX; |
| 178 | std::unique_ptr < std::deque<std::unique_ptr<Bin>>>* oldqueue; |
| 179 | for (std::map<std::string, std::unique_ptr<std::deque<std::unique_ptr<Bin>>>>::iterator it=groupBinMap_.begin(); it !=groupBinMap_.end(); ++it) { |
| 180 | std::unique_ptr < std::deque<std::unique_ptr<Bin>>>&queue = it->second; |
| 181 | if (!queue->empty()) { |
| 182 | std::unique_ptr<Bin> &bin = queue->front(); |
| 183 | if (bin->getBinAge() < olddate) { |
| 184 | olddate = bin->getBinAge(); |
| 185 | oldqueue = &queue; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | if (olddate != ULLONG_MAX) { |
| 190 | std::unique_ptr<Bin> &remove = (*oldqueue)->front(); |
| 191 | std::string group = remove->getGroupId(); |
| 192 | readyBin_.push_back(std::move(remove)); |
| 193 | (*oldqueue)->pop_front(); |
| 194 | binCount_--; |
| 195 | logger_->log_debug("BinManager move bin %s to ready bins for group %s", readyBin_.back()->getUUIDStr(), readyBin_.back()->getGroupId()); |
| 196 | if ((*oldqueue)->empty()) { |
| 197 | groupBinMap_.erase(group); |
| 198 | } |
| 199 | } |
| 200 | logger_->log_debug("BinManager groupBinMap size %d", groupBinMap_.size()); |
| 201 | } |
| 202 | |
| 203 | void BinManager::getReadyBin(std::deque<std::unique_ptr<Bin>> &retBins) { |
| 204 | std::lock_guard < std::mutex > lock(mutex_); |
no test coverage detected