| 44 | |
| 45 | |
| 46 | __hot |
| 47 | void* ConcurrentArena::alloc(size_t size) { |
| 48 | uint8_t *result, *newNext, *nextBlock = _nextBlock; |
| 49 | do { |
| 50 | result = nextBlock; |
| 51 | newNext = nextBlock + size; |
| 52 | if (newNext > _heapEnd) |
| 53 | return nullptr; // overflow |
| 54 | } while (!_nextBlock.compare_exchange_weak(nextBlock, newNext, memory_order_acq_rel)); |
| 55 | return result; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | __hot |