| 735 | }; |
| 736 | |
| 737 | static Block* make_block(size_t capacity) AE_NO_TSAN |
| 738 | { |
| 739 | // Allocate enough memory for the block itself, as well as all the elements |
| 740 | // it will contain |
| 741 | auto size = sizeof(Block) + std::alignment_of<Block>::value - 1; |
| 742 | size += sizeof(T) * capacity + std::alignment_of<T>::value - 1; |
| 743 | auto newBlockRaw = static_cast<char*>(std::malloc(size)); |
| 744 | if (newBlockRaw == nullptr) |
| 745 | return nullptr; |
| 746 | |
| 747 | auto newBlockAligned = align_for<Block>(newBlockRaw); |
| 748 | auto newBlockData = align_for<T>(newBlockAligned + sizeof(Block)); |
| 749 | return new (newBlockAligned) Block(capacity, newBlockRaw, newBlockData); |
| 750 | } |
| 751 | |
| 752 | private: |
| 753 | weak_atomic<Block*> frontBlock; // (Atomic) Elements are dequeued from this block |
no outgoing calls
no test coverage detected