TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Main Page
Namespaces
Classes
3rdparty
torchcraft
include
torchcraft
refcount.h
1
/**
2
* Copyright (c) 2015-present, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*/
9
10
#pragma once
11
12
#include <atomic>
13
14
/*
15
* Reference counting for Frames and Replayers.
16
*
17
* Enables frames and replayers to be referenced by Lua variables and other
18
* C++ objects at the same time.
19
*
20
* We cannot use a C++ shared_pointer because that doesn't help us with the
21
* interaction with Lua.
22
*/
23
class
RefCounted
{
24
private
:
25
std::atomic_int refs;
26
27
public
:
28
RefCounted
() {
29
refs = 1;
30
}
31
// Destructor needs to be virtual for delete this to work correctly.
32
virtual
~RefCounted
() {}
33
34
void
incref
() {
35
refs++;
36
}
37
void
decref
() {
38
if
(--refs == 0)
39
delete
this
;
40
}
41
};
RefCounted::~RefCounted
virtual ~RefCounted()
Definition:
refcount.h:32
RefCounted::RefCounted
RefCounted()
Definition:
refcount.h:28
RefCounted
Copyright (c) 2015-present, Facebook, Inc.
Definition:
refcount.h:23
RefCounted::incref
void incref()
Definition:
refcount.h:34
RefCounted::decref
void decref()
Definition:
refcount.h:37
Generated on Wed Apr 17 2019 18:31:56 for TorchCraftAI by
1.8.11