当前位置: 首页>>代码示例>>C++>>正文


C++ Admin::retains方法代码示例

本文整理汇总了C++中Admin::retains方法的典型用法代码示例。如果您正苦于以下问题:C++ Admin::retains方法的具体用法?C++ Admin::retains怎么用?C++ Admin::retains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Admin的用法示例。


在下文中一共展示了Admin::retains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dec_refcount_no_lock

 usword_t SubzoneBlockRef::dec_refcount_no_lock() const {
     Admin *admin = subzone()->admin();
     if (has_refcount()) {
         // non-zero reference count, check the overflow table.
         PtrIntHashMap &retains = admin->retains();
         PtrIntHashMap::iterator retain_iter = retains.find(address());
         if (retain_iter != retains.end() && retain_iter->first == address()) {
             if (--retain_iter->second == 1) {
                 // transition from 2 -> 1
                 retains.erase(retain_iter);
                 return 1;
             } else {
                 return retain_iter->second;
             }
         } else {
             // transition from 1 -> 0
             subzone()->clear_has_refcount(q());
             return 0;
         }
     }
     // underflow.
     malloc_printf("reference count underflow for %p, break on auto_refcount_underflow_error to debug.\n", address());
     auto_refcount_underflow_error(address());
     return -1;
 }
开发者ID:unofficial-opensource-apple,项目名称:libauto,代码行数:25,代码来源:BlockRef.cpp

示例2: refcount

 usword_t SubzoneBlockRef::refcount() const {
     int refcount = 0;
     Admin *admin = subzone()->admin();
     SpinLock lock(admin->lock());
     if (has_refcount()) {
         // non-zero reference count, check the overflow table.
         // BlockRef FIXME: use q instead of address in hash map?
         PtrIntHashMap &retains = admin->retains();
         PtrIntHashMap::iterator retain_iter = retains.find(address());
         if (retain_iter != retains.end() && retain_iter->first == address()) {
             refcount = retain_iter->second;
         } else {
             refcount = 1;
         }
     }
     return refcount;
 }
开发者ID:unofficial-opensource-apple,项目名称:libauto,代码行数:17,代码来源:BlockRef.cpp

示例3: inc_refcount

 usword_t SubzoneBlockRef::inc_refcount() const { 
     int refcount;
     Admin *admin = subzone()->admin();
     SpinLock lock(admin->lock());
     void *block = address();
     if (has_refcount()) {
         // non-trivial reference count, check the overflow table.
         PtrIntHashMap &retains = admin->retains();
         PtrIntHashMap::iterator retain_iter = retains.find(block);
         if (retain_iter != retains.end() && retain_iter->first == block) {
             refcount = ++retain_iter->second;
         } else {
             // transition from 1 -> 2
             refcount = (retains[block] = 2);
         }
     } else {
         // transition from 0 -> 1
         Thread &thread = admin->zone()->registered_thread();
         thread.block_escaped(*this);
         subzone()->set_has_refcount(q());
         refcount = 1;
     }
     return refcount;
 }
开发者ID:unofficial-opensource-apple,项目名称:libauto,代码行数:24,代码来源:BlockRef.cpp


注:本文中的Admin::retains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。