IAtari
Genetic algorithm generating AI capable to play Atari2600 games.
SMP.h
Go to the documentation of this file.
1
/*
2
This file is part of Leela Zero.
3
Copyright (C) 2017 Gian-Carlo Pascutto
4
5
Leela Zero is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
Leela Zero is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with Leela Zero. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef SMP_H_INCLUDED
20
#define SMP_H_INCLUDED
21
22
#include <atomic>
23
24
namespace
SMP
{
25
int
get_num_cpus
();
26
27
class
Mutex
{
28
public
:
29
Mutex
();
30
~Mutex
() =
default
;
31
friend
class
Lock
;
32
private
:
33
std::atomic<bool> m_lock;
34
};
35
36
class
Lock
{
37
public
:
38
explicit
Lock
(
Mutex
& m);
39
~Lock
();
40
void
lock
();
41
void
unlock
();
42
private
:
43
Mutex
* m_mutex;
44
};
45
}
46
47
// Avoids accidentally creating a temporary
48
#define LOCK(mutex, lock) SMP::Lock lock((mutex))
49
50
#endif
SMP::Lock::Lock
Lock(Mutex &m)
Definition:
SMP.cpp:27
SMP::Lock::~Lock
~Lock()
Definition:
SMP.cpp:40
SMP::Mutex::Mutex
Mutex()
Definition:
SMP.cpp:23
SMP::get_num_cpus
int get_num_cpus()
Definition:
SMP.cpp:44
SMP::Lock
Definition:
SMP.h:36
SMP
Definition:
SMP.h:24
SMP::Mutex::~Mutex
~Mutex()=default
SMP::Mutex
Definition:
SMP.h:27
SMP::Lock::lock
void lock()
Definition:
SMP.cpp:32
SMP::Lock::unlock
void unlock()
Definition:
SMP.cpp:36
SMP.h
Generated by
1.8.15