本文整理匯總了C++中DEBUG_REFCNT函數的典型用法代碼示例。如果您正苦於以下問題:C++ DEBUG_REFCNT函數的具體用法?C++ DEBUG_REFCNT怎麽用?C++ DEBUG_REFCNT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DEBUG_REFCNT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: dm_assoc_find
static hash_item *do_item_get(struct demo_engine *engine,
const char *key, const size_t nkey,
bool LRU_reposition)
{
rel_time_t current_time = engine->server.core->get_current_time();
hash_item *it = dm_assoc_find(engine, engine->server.core->hash(key, nkey, 0),
key, nkey);
if (it != NULL) {
if (do_item_isvalid(engine, it, current_time)==false) {
do_item_unlink(engine, it, ITEM_UNLINK_INVALID);
it = NULL;
}
}
if (it != NULL) {
ITEM_REFCOUNT_INCR(it);
DEBUG_REFCNT(it, '+');
}
if (engine->config.verbose > 2) {
if (it == NULL) {
logger->log(EXTENSION_LOG_INFO, NULL, "> NOT FOUND %s\n",
key);
} else {
logger->log(EXTENSION_LOG_INFO, NULL, "> FOUND KEY %s\n",
(const char*)dm_item_get_key(it));
}
}
return it;
}
示例2: assoc_find
/** wrapper around assoc_find which does the lazy expiration/deletion logic */
item *do_item_get_notedeleted(const char *key, const size_t nkey, bool *delete_locked) {
item *it = assoc_find(key, nkey);
int was_found = 0;
if (delete_locked) *delete_locked = false;
if (settings.verbose > 2) {
if (it == NULL) {
fprintf(stderr, "> NOT FOUND %s", key);
} else {
fprintf(stderr, "> FOUND KEY %s", ITEM_key(it));
was_found++;
}
}
if (it != NULL && (it->it_flags & ITEM_DELETED)) {
/* it's flagged as delete-locked. let's see if that condition
is past due, and the 5-second delete_timer just hasn't
gotten to it yet... */
if (!item_delete_lock_over(it)) {
if (delete_locked) *delete_locked = true;
it = NULL;
}
}
if (it == NULL && was_found) {
fprintf(stderr, " -nuked by delete lock");
was_found--;
}
if (it != NULL && settings.oldest_live != 0 && settings.oldest_live <= current_time &&
it->time <= settings.oldest_live) {
do_item_unlink(it); /* MTSAFE - cache_lock held */
it = NULL;
}
if (it == NULL && was_found) {
fprintf(stderr, " -nuked by flush");
was_found--;
}
if (it != NULL && it->exptime != 0 && it->exptime <= current_time) {
do_item_unlink(it); /* MTSAFE - cache_lock held */
it = NULL;
}
if (it == NULL && was_found) {
fprintf(stderr, " -nuked by expire");
was_found--;
}
if (it != NULL) {
it->refcount++;
DEBUG_REFCNT(it, '+');
}
if (settings.verbose > 2)
fprintf(stderr, "\n");
return it;
}
示例3: assoc_find
/** wrapper around assoc_find which does the lazy expiration logic */
hash_item *do_item_get(struct default_engine *engine,
const hash_key *key) {
rel_time_t current_time = engine->server.core->get_current_time();
hash_item *it = assoc_find(engine,
crc32c(hash_key_get_key(key),
hash_key_get_key_len(key), 0),
key);
int was_found = 0;
if (engine->config.verbose > 2) {
EXTENSION_LOGGER_DESCRIPTOR *logger;
logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
if (it == NULL) {
logger->log(EXTENSION_LOG_DEBUG, NULL,
"> NOT FOUND in bucket %d, %s",
hash_key_get_bucket_index(key),
hash_key_get_client_key(key));
} else {
logger->log(EXTENSION_LOG_DEBUG, NULL,
"> FOUND KEY in bucket %d, %s",
hash_key_get_bucket_index(item_get_key(it)),
hash_key_get_client_key(item_get_key(it)));
was_found++;
}
}
if (it != NULL && engine->config.oldest_live != 0 &&
engine->config.oldest_live <= current_time &&
it->time <= engine->config.oldest_live) {
do_item_unlink(engine, it); /* MTSAFE - items.lock held */
it = NULL;
}
if (it == NULL && was_found) {
EXTENSION_LOGGER_DESCRIPTOR *logger;
logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
logger->log(EXTENSION_LOG_DEBUG, NULL, " -nuked by flush");
was_found--;
}
if (it != NULL && it->exptime != 0 && it->exptime <= current_time) {
do_item_unlink(engine, it); /* MTSAFE - items.lock held */
it = NULL;
}
if (it == NULL && was_found) {
EXTENSION_LOGGER_DESCRIPTOR *logger;
logger = (void*)engine->server.extension->get_extension(EXTENSION_LOGGER);
logger->log(EXTENSION_LOG_DEBUG, NULL, " -nuked by expire");
was_found--;
}
if (it != NULL) {
it->refcount++;
DEBUG_REFCNT(it, '+');
do_item_update(engine, it);
}
return it;
}
示例4: assoc_find
/** wrapper around assoc_find which does the lazy expiration/deletion logic */
item *do_item_get_notedeleted(const char *key, const size_t nkey, bool *delete_locked) {
item *it = assoc_find(key, nkey);
if (delete_locked) *delete_locked = false;
if (it != NULL && (it->it_flags & ITEM_DELETED)) {
/* it's flagged as delete-locked. let's see if that condition
is past due, and the 5-second delete_timer just hasn't
gotten to it yet... */
if (!item_delete_lock_over(it)) {
if (delete_locked) *delete_locked = true;
it = NULL;
}
}
if (it != NULL && settings.oldest_live != 0 && settings.oldest_live <= current_time &&
it->time <= settings.oldest_live) {
do_item_unlink(it); /* MTSAFE - cache_lock held */
it = NULL;
}
if (it != NULL && it->exptime != 0 && it->exptime <= current_time) {
do_item_unlink(it); /* MTSAFE - cache_lock held */
it = NULL;
}
if (it != NULL) {
it->refcount++;
DEBUG_REFCNT(it, '+');
}
return it;
}
示例5: mutex_lock
/** wrapper around assoc_find which does the lazy expiration logic */
item *do_item_get(const char *key, const size_t nkey, const uint32_t hv) {
mutex_lock(&cache_lock);
item *it = assoc_find(key, nkey, hv);
if (it != NULL) {
refcount_incr(&it->refcount);
/* Optimization for slab reassignment. prevents popular items from
* jamming in busy wait. Can only do this here to satisfy lock order
* of item_lock, cache_lock, slabs_lock. */
if (slab_rebalance_signal &&
((void *)it >= slab_rebal.slab_start && (void *)it < slab_rebal.slab_end)) {
do_item_unlink_nolock(it, hv);
do_item_remove(it);
it = NULL;
}
}
pthread_mutex_unlock(&cache_lock);
int was_found = 0;
if (settings.verbose > 2) {
if (it == NULL) {
fprintf(stderr, "> NOT FOUND %s", key);
} else {
fprintf(stderr, "> FOUND KEY %s", ITEM_key(it));
was_found++;
}
}
if (it != NULL) {
if (settings.oldest_live != 0 && settings.oldest_live <= current_time &&
it->time <= settings.oldest_live) {
do_item_unlink(it, hv);
do_item_remove(it);
it = NULL;
if (was_found) {
fprintf(stderr, " -nuked by flush");
}
} else if (it->exptime != 0 && it->exptime <= current_time) {
if (it->exptime + 10 < current_time) {
do_item_unlink(it, hv);
do_item_remove(it);
if (was_found) {
fprintf(stderr, " -nuked by expire");
}
} else {
/* re-active just expired items, to anti miss-storm */
it->exptime = current_time + 10;
}
it = NULL;
} else {
it->it_flags |= ITEM_FETCHED;
DEBUG_REFCNT(it, '+');
}
}
if (settings.verbose > 2)
fprintf(stderr, "\n");
return it;
}
示例6: do_item_free
static void do_item_free(struct demo_engine *engine, hash_item *it)
{
assert((it->iflag & ITEM_LINKED) == 0);
assert(it->refcount == 0);
it->slabs_clsid = 0;
DEBUG_REFCNT(it, 'F');
free(it);
}
示例7: do_item_release
void do_item_release(struct default_engine *engine, hash_item *it) {
MEMCACHED_ITEM_REMOVE(item_get_key(it), it->nkey, it->nbytes);
if (it->refcount != 0) {
it->refcount--;
DEBUG_REFCNT(it, '-');
}
if (it->refcount == 0 && (it->iflag & ITEM_LINKED) == 0) {
item_free(engine, it);
}
}
示例8: do_item_remove
void do_item_remove(item *it) {
if (it->refcount != 0) {
it->refcount--;
DEBUG_REFCNT(it, '-');
}
assert((it->it_flags & ITEM_DELETED) == 0 || it->refcount != 0);
if (it->refcount == 0 && (it->it_flags & ITEM_LINKED) == 0) {
item_free(it);
}
}
示例9: do_item_remove
void do_item_remove(item *it) {
MEMCACHED_ITEM_REMOVE(ITEM_key(it), it->nkey, it->nbytes);
assert((it->it_flags & ITEM_SLABBED) == 0);
if (it->refcount != 0) {
it->refcount--;
DEBUG_REFCNT(it, '-');
}
if (it->refcount == 0 && (it->it_flags & ITEM_LINKED) == 0) {
item_free(it);
}
}
示例10: item_free
void item_free(item *it) {
size_t ntotal = ITEM_ntotal(it);
assert((it->it_flags & ITEM_LINKED) == 0);
assert(it != heads[it->slabs_clsid]);
assert(it != tails[it->slabs_clsid]);
assert(it->refcount == 0);
/* so slab size changer can tell later if item is already free or not */
it->slabs_clsid = 0;
it->it_flags |= ITEM_SLABBED;
DEBUG_REFCNT(it, 'F');
slabs_free(it, ntotal);
}
示例11: do_item_release
static void do_item_release(struct demo_engine *engine, hash_item *it)
{
MEMCACHED_ITEM_REMOVE(dm_item_get_key(it), it->nkey, it->nbytes);
if (it->refcount != 0) {
ITEM_REFCOUNT_DECR(it);
DEBUG_REFCNT(it, '-');
}
if (it->refcount == 0) {
if ((it->iflag & ITEM_LINKED) == 0) {
do_item_free(engine, it);
}
}
}
示例12: item_free
//將item內存置為空閑,以供再使用,這裏的free不是把內存空間釋放
void item_free(item *it) {
size_t ntotal = ITEM_ntotal(it);
unsigned int clsid;
assert((it->it_flags & ITEM_LINKED) == 0);
assert(it != heads[it->slabs_clsid]);
assert(it != tails[it->slabs_clsid]);
assert(it->refcount == 0);
/* so slab size changer can tell later if item is already free or not */
clsid = it->slabs_clsid;
it->slabs_clsid = 0; //free掉的 item的slabs_clsid設為0
DEBUG_REFCNT(it, 'F');
slabs_free(it, ntotal, clsid);
}
示例13: item_free
//釋放item
void item_free(item *it) {
size_t ntotal = ITEM_ntotal(it);//獲得item的大小
unsigned int clsid;
assert((it->it_flags & ITEM_LINKED) == 0);//判斷item的狀態是否正確
assert(it != heads[it->slabs_clsid]);//item不能為LRU的頭指針
assert(it != tails[it->slabs_clsid]);//item不能為LRU的尾指針
assert(it->refcount == 0);//釋放時,需保證引用次數為0
/* so slab size changer can tell later if item is already free or not */
clsid = it->slabs_clsid;
it->slabs_clsid = 0;//斷開slabclass的鏈接
DEBUG_REFCNT(it, 'F');
slabs_free(it, ntotal, clsid);//slabclass結構執行釋放
}
示例14: item_free
//釋放item
void item_free(item *it) {
syslog(LOG_INFO, "[%s:%s:%d]", __FILE__, __func__, __LINE__);
size_t ntotal = ITEM_ntotal(it);
unsigned int clsid;
assert((it->it_flags & ITEM_LINKED) == 0);//沒有在hash表和LUR鏈中
assert(it != heads[it->slabs_clsid]);
assert(it != tails[it->slabs_clsid]);
assert(it->refcount == 0);
/* so slab size changer can tell later if item is already free or not */
clsid = it->slabs_clsid;
it->slabs_clsid = 0;
DEBUG_REFCNT(it, 'F');
slabs_free(it, ntotal, clsid);
}
示例15: item_free
void item_free(item *it) {
size_t ntotal = ITEM_ntotal(it);
unsigned int clsid;
assert((it->it_flags & ITEM_LINKED) == 0);
assert(it->refcount == 0);
/* so slab size changer can tell later if item is already free or not */
clsid = it->slabs_clsid;
it->slabs_clsid = 0;
// it->it_flags |= ITEM_SLABBED;
DEBUG_REFCNT(it, 'F');
//[TODO] allocate management
zfree(it);
}