| 77 | } |
| 78 | |
| 79 | void ExperimentalPMemAllocator::BackgroundWork() { |
| 80 | while (1) { |
| 81 | if (closing_) return; |
| 82 | usleep(bg_thread_interval_ * 1000000); |
| 83 | // Move cached list to pool |
| 84 | std::vector<void*> moving_list; |
| 85 | for (size_t i = 0; i < thread_cache_.size(); i++) { |
| 86 | auto& tc = thread_cache_[i]; |
| 87 | moving_list.clear(); |
| 88 | for (size_t b_size = 1; b_size < tc.freelists.size(); b_size++) { |
| 89 | moving_list.clear(); |
| 90 | std::lock_guard<spin_lock> lg(tc.locks[b_size]); |
| 91 | |
| 92 | if (tc.freelists[b_size].size() >= kMinMovableListSize) { |
| 93 | if (tc.freelists[b_size].size() >= kMinMovableListSize) { |
| 94 | moving_list.swap(tc.freelists[b_size]); |
| 95 | } |
| 96 | } |
| 97 | if (moving_list.size() > 0) { |
| 98 | pool_.MoveEntryList(moving_list, b_size); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | ExperimentalPMemAllocator::ExperimentalPMemAllocator( |
| 106 | char* pmem, const std::string& pmem_file_name, uint64_t pmem_size, |
no test coverage detected