SHOGUN
4.1.0
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
lib
RefCount.cpp
浏览该文件的文档.
1
#include <
shogun/lib/RefCount.h
>
2
3
using namespace
shogun
;
4
5
int32_t
RefCount::ref
()
6
{
7
#ifdef HAVE_CXX11_ATOMIC
8
int32_t count =
rc
.fetch_add(1)+1;
9
#else
10
lock
.
lock
();
11
int32_t count = ++
rc
;
12
lock
.
unlock
();
13
#endif
14
15
return
count;
16
}
17
18
int32_t
RefCount::unref
()
19
{
20
#ifdef HAVE_CXX11_ATOMIC
21
int32_t count =
rc
.fetch_sub(1)-1;
22
#else
23
lock
.
lock
();
24
int32_t count = --
rc
;
25
lock
.
unlock
();
26
#endif
27
28
return
count;
29
}
30
31
int32_t
RefCount::ref_count
()
32
{
33
#ifdef HAVE_CXX11_ATOMIC
34
int32_t count =
rc
.load();
35
#else
36
lock
.
lock
();
37
int32_t count =
rc
;
38
lock
.
unlock
();
39
#endif
40
41
return
count;
42
}
shogun::RefCount::ref_count
int32_t ref_count()
Definition:
RefCount.cpp:31
RefCount.h
shogun::RefCount::lock
CLock lock
Definition:
RefCount.h:52
shogun::CLock::unlock
void unlock()
Definition:
Lock.cpp:64
shogun::RefCount::unref
int32_t unref()
Definition:
RefCount.cpp:18
shogun::RefCount::ref
int32_t ref()
Definition:
RefCount.cpp:5
shogun
all of classes and functions are contained in the shogun namespace
Definition:
class_list.h:18
shogun::RefCount::rc
int32_t rc
Definition:
RefCount.h:49
shogun::CLock::lock
void lock()
Definition:
Lock.cpp:57
SHOGUN
机器学习工具包 - 项目文档