bid_words_ / ask_words_ bit radar; __builtin_ctzll / __builtin_clzll
Fills
Optional RingBuffer<ExecutionReceipt>*; one push per fill when attached
Memory layout
For price_level_count = N, level_queue_capacity = Q (power of two):
Structure
Shape
bid_pool_, ask_pool_
order_pool_capacity × Order each
bid_levels_, ask_levels_
N × PriceLevel
bid_orders_, ask_orders_
N × Q × OrderRef
bid_words_, ask_words_
⌈N / 64⌉ × uint64_t
locators_
max_order_id + 1 × Locator
Each PriceLevel binds to orders_ + tick × Q at construction. Ring indices use mask = Q - 1.
add_order pipeline
validate (volume, tick, order_id, duplicate active id)
if Limit+GTC: inline fast path in header
else: forward to add_order_slow (Market / IOC / FOK)
match_buy | match_sell
clean_front (skip invalid head; compact after 8 consecutive stale pops)
fill FIFO head at best opposite price
push ExecutionReceipt if ring attached
erase best price when level volume reaches zero
rest_order if incoming volume > 0
allocate pool slot, push OrderRef, update locator, set radar bit and best price
return AddResult (matched/rested/dropped volumes)