65 next_[i].~atomic_uint32_t();
86 memset(
blocks_, 0xCD, block_size * block_count);
92 if (i == block_count_ - 1)
94 next_[i].store(0xffffffffUL);
98 next_[i].store(i + 1);
121 typename Debug::Item i;
127 if (
getVal(head) == 0xffffffffULL)
130 debug_->items.push_back(i);
146 i.new_head = new_head;
152 if (
head_.compare_exchange_strong(head, new_head))
157 debug_->items.push_back(i);
165 debug_->items.push_back(i);
192 typename Debug::Item i;
200 uint64_t new_head = head;
215 i.new_head = new_head;
221 if (
head_.compare_exchange_strong(head, new_head))
225 i.addr =
blocks_ + (block_size_ * index);
226 debug_->items.push_back(i);
234 debug_->items.push_back(i);
241 uint32_t sub = (
static_cast<uint8_t const*
>(mem) -
blocks_);
#define ROSRT_CACHELINE_SIZE
void free(void const *mem)
Free a block of memory allocated from this FreeList.
void * allocate()
Allocate a single block from this FreeList.
FreeList()
Default constructor. You must call initialize() if you use this constructor.
#define FREELIST_DEBUG_YIELD()
bool owns(void const *mem)
Returns whether or not this FreeList owns a block of memory.
uint32_t getVal(uint64_t val)
ros::atomic_uint32_t alloc_count_
void setVal(uint64_t &val, uint32_t v)
ros::atomic_uint32_t * next_
bool hasOutstandingAllocations()
Returns whether or not this FreeList currently has any outstanding allocations.
void setTag(uint64_t &val, uint32_t tag)
void * alignedMalloc(size_t size, size_t alignment)
atomic< uint32_t > atomic_uint32_t
void alignedFree(void *aligned)
uint32_t getTag(uint64_t val)
ros::atomic_uint64_t head_
void initialize(uint32_t block_size, uint32_t block_count)
Initialize this FreeList. Only use if you used to default constructor.