void nmb_put(struct nmb *nmb, MSN msn, msgtype_t type, struct msg *key, struct msg *val, struct txnid_pair *xidpair) { char *base; uint32_t size = (NMB_ENTRY_SIZE + key->size); if (type != MSG_DELETE) size += val->size; ness_rwlock_write_lock(&nmb->rwlock); base = mempool_alloc_aligned(nmb->mpool, size); ness_rwlock_write_unlock(&nmb->rwlock); _nmb_entry_pack(base, msn, type, key, val, xidpair); /* pma is thread-safe */ pma_insert(nmb->pma, (void*)base, _nmb_entry_key_compare, (void*)nmb); atomic_fetch_and_inc(&nmb->count); }
struct skipnode *_new_node(struct skiplist *sl, int height) { uint32_t sizes; struct skipnode *n; sizes = (sizeof(*n) + (height - 1) * sizeof(void*)); n = (struct skipnode*)mempool_alloc_aligned(sl->mpool, sizes); memset(n, 0, sizes); return n; }
void nmb_put(struct nmb *nmb, MSN msn, msgtype_t type, struct msg *key, struct msg *val, struct txnid_pair *xidpair) { char *base; uint32_t size = 0U; size += (MSGENTRY_SIZE + key->size); if (type != MSG_DELETE) size += val->size; base = mempool_alloc_aligned(nmb->mpool, size); msgentry_pack(base, msn, type, key, val, xidpair); pma_insert(nmb->pma, (void*)base, size, msgentry_key_compare); nmb->count++; nmb->memory_used += size; }