SHOGUN
4.2.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
src
shogun
lib
RefCount.cpp
Go to the documentation of this file.
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
Machine Learning Toolbox - Documentation