| 70 | alignas(64) std::atomic<TRootNode*> FreePtr; |
| 71 | |
| 72 | void TryToFreeAsyncMemory() { |
| 73 | const auto keepCounter = FreeingTaskCounter.load(); |
| 74 | TRootNode* current = FreePtr.load(std::memory_order_acquire); |
| 75 | if (current == nullptr) { |
| 76 | return; |
| 77 | } |
| 78 | if (FreememCounter.load() == 1) { |
| 79 | // we are the last thread, try to cleanup |
| 80 | // check if another thread have cleaned up |
| 81 | if (keepCounter != FreeingTaskCounter.load()) { |
| 82 | return; |
| 83 | } |
| 84 | if (FreePtr.compare_exchange_strong(current, nullptr)) { |
| 85 | // free list |
| 86 | while (current) { |
| 87 | TRootNode* p = current->NextFree.load(std::memory_order_acquire); |
| 88 | EraseList(current->ToDelete.load(std::memory_order_acquire)); |
| 89 | delete current; |
| 90 | current = p; |
| 91 | } |
| 92 | ++FreeingTaskCounter; |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | void AsyncRef() { |
| 97 | ++FreememCounter; |
| 98 | } |
nothing calls this directly
no test coverage detected