From a22560c3ccaf19261b5c40fdcab36d2d22426986 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 7 Jun 2014 16:58:20 -0400 Subject: Use // comments when possible. --- libdimension/pool.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'libdimension/pool.c') diff --git a/libdimension/pool.c b/libdimension/pool.c index 8973371..bd31677 100644 --- a/libdimension/pool.c +++ b/libdimension/pool.c @@ -26,30 +26,30 @@ #include "dimension-internal.h" #include -/** A single allocation and associated destructor. */ +/// A single allocation and associated destructor. typedef struct dmnsn_allocation { void *ptr; dmnsn_callback_fn *cleanup_fn; } dmnsn_allocation; -/** Number of pointers per block, we want a block to fit in a single page. */ +/// Number of pointers per block, we want a block to fit in a single page. #define DMNSN_POOL_BLOCK_SIZE ((4096 - 4*sizeof(void *))/sizeof(dmnsn_allocation)) -/** A single block in a thread pool. */ +/// A single block in a thread pool. typedef struct dmnsn_pool_block { - /** Current index into allocs[]. */ + /// Current index into allocs[]. size_t i; - /** All allocations in the current block. */ + /// All allocations in the current block. dmnsn_allocation allocs[DMNSN_POOL_BLOCK_SIZE]; - /** Tail pointer to the previous block in the global chain. */ + /// Tail pointer to the previous block in the global chain. struct dmnsn_pool_block *prev; } dmnsn_pool_block; -/** dmnsn_pool implementation. */ +/// dmnsn_pool implementation. struct dmnsn_pool { - /** Thread-local block. */ + /// Thread-local block. pthread_key_t thread_block; - /** Global chain of pools. */ + /// Global chain of pools. _Atomic(dmnsn_pool_block *) chain; }; @@ -87,7 +87,7 @@ dmnsn_palloc_tidy(dmnsn_pool *pool, size_t size, dmnsn_callback_fn *cleanup_fn) if (dmnsn_unlikely(new_block != old_block)) { dmnsn_setspecific(pool->thread_block, new_block); - /* Atomically update pool->chain */ + // Atomically update pool->chain dmnsn_pool_block *chain; do { chain = atomic_load(&pool->chain); @@ -107,7 +107,7 @@ dmnsn_delete_pool(dmnsn_pool *pool) dmnsn_pool_block *block = atomic_load_explicit(&pool->chain, memory_order_relaxed); while (block) { - /* Free all the allocations in reverse order */ + // Free all the allocations in reverse order for (size_t i = block->i; i-- > 0;) { dmnsn_allocation *alloc = block->allocs + i; if (alloc->cleanup_fn) { @@ -116,7 +116,7 @@ dmnsn_delete_pool(dmnsn_pool *pool) dmnsn_free(alloc->ptr); } - /* Free the block itself and go to the previous one */ + // Free the block itself and go to the previous one dmnsn_pool_block *saved = block; block = block->prev; dmnsn_free(saved); -- cgit v1.2.3