Note: The queue should not be accessed concurrently while it's being deleted. It's up to the user to synchronize this. This method is not thread safe.
| 835 | // being deleted. It's up to the user to synchronize this. |
| 836 | // This method is not thread safe. |
| 837 | ~ConcurrentQueue() |
| 838 | { |
| 839 | // Destroy producers |
| 840 | auto ptr = producerListTail.load(std::memory_order_relaxed); |
| 841 | while (ptr != nullptr) { |
| 842 | auto next = ptr->next_prod(); |
| 843 | if (ptr->token != nullptr) { |
| 844 | ptr->token->producer = nullptr; |
| 845 | } |
| 846 | destroy(ptr); |
| 847 | ptr = next; |
| 848 | } |
| 849 | |
| 850 | // Destroy implicit producer hash tables |
| 851 | MOODYCAMEL_CONSTEXPR_IF (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE != 0) { |
| 852 | auto hash = implicitProducerHash.load(std::memory_order_relaxed); |
| 853 | while (hash != nullptr) { |
| 854 | auto prev = hash->prev; |
| 855 | if (prev != nullptr) { // The last hash is part of this object and was not allocated dynamically |
| 856 | for (size_t i = 0; i != hash->capacity; ++i) { |
| 857 | hash->entries[i].~ImplicitProducerKVP(); |
| 858 | } |
| 859 | hash->~ImplicitProducerHash(); |
| 860 | (Traits::free)(hash); |
| 861 | } |
| 862 | hash = prev; |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | // Destroy global free list |
| 867 | auto block = freeList.head_unsafe(); |
| 868 | while (block != nullptr) { |
| 869 | auto next = block->freeListNext.load(std::memory_order_relaxed); |
| 870 | if (block->dynamicallyAllocated) { |
| 871 | destroy(block); |
| 872 | } |
| 873 | block = next; |
| 874 | } |
| 875 | |
| 876 | // Destroy initial free list |
| 877 | destroy_array(initialBlockPool, initialBlockPoolSize); |
| 878 | } |
| 879 | |
| 880 | // Disable copying and copy assignment |
| 881 | ConcurrentQueue(ConcurrentQueue const&) MOODYCAMEL_DELETE_FUNCTION; |
nothing calls this directly
no test coverage detected