Esempio n. 1
0
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);
}
Esempio n. 2
0
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;

	base = mempool_alloc_aligned(nmb->mpool, size);
	_nmb_entry_pack(base, msn, type, key, val, xidpair);
	pma_insert(nmb->pma,
	           (void*)base,
	           _nmb_entry_key_compare,
	           (void*)nmb->e);
	nmb->count++;
}