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