| 654 | } |
| 655 | |
| 656 | void CoalescedHashTable::ClearMatchedKeys( |
| 657 | const std::function<bool(int64)>& match, |
| 658 | const std::function<void(Status)>& done) { |
| 659 | mutex_lock lock(update_mu_); |
| 660 | std::vector<int64> ids; |
| 661 | for (int64 i = 0; i < num_tables_; ++i) { |
| 662 | for (auto iter = tables_[i].begin(); iter != tables_[i].end(); ) { |
| 663 | if (match(iter->first)) { |
| 664 | ids.push_back(iter->second); |
| 665 | iter = tables_[i].erase(iter); |
| 666 | if (ids.back() != kNotAdmitted) { |
| 667 | ids_allocator_.FreeId(ids.back()); |
| 668 | } |
| 669 | } else { |
| 670 | ++iter; |
| 671 | } |
| 672 | } |
| 673 | } |
| 674 | StatusCollector* stc = new StatusCollector(tensors_.size(), done); |
| 675 | for (auto&& tensor : tensors_) { |
| 676 | tensor->ClearIds(ids.data(), ids.size(), stc->AddStatusFunc()); |
| 677 | } |
| 678 | stc->Start(); |
| 679 | } |
| 680 | |
| 681 | } // namespace tensorflow |