MCPcopy Create free account
hub / github.com/cameron314/readerwriterqueue / make_block

Function make_block

readerwriterqueue.h:728–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
743private:
744 weak_atomic<Block*> frontBlock; // (Atomic) Elements are dequeued from this block

Callers 2

inner_enqueueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected