Cytopia
0.3
A city building simulation game
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
Functions
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
z
~
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
a
c
d
e
g
i
m
n
p
r
s
t
u
v
Enumerations
Enumerator
Related Functions
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
z
Functions
b
c
d
f
g
i
m
o
p
r
s
t
w
Variables
a
c
d
g
h
i
l
m
n
r
s
t
Typedefs
a
c
d
e
f
g
i
j
l
m
n
r
s
t
v
Enumerations
Enumerator
a
b
d
e
f
g
l
m
n
p
r
s
t
u
w
z
Macros
_
c
e
i
l
n
r
s
t
v
Examples
▼
Cytopia
Todo List
►
Namespaces
►
Classes
▼
Files
▼
File List
▼
src
►
engine
►
game
►
scripting
▼
services
►
AudioMixer.cxx
►
AudioMixer.hxx
►
GameClock.cxx
►
GameClock.hxx
GameClock.inl.hxx
Randomizer.cxx
►
Randomizer.hxx
►
ResourceManager.cxx
►
ResourceManager.hxx
►
ResourceManager.inl.hxx
►
util
►
windows
Game.cxx
►
Game.hxx
►
main.cxx
►
MainMenu.cxx
►
MainMenu.hxx
phc.hxx
►
File Members
►
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
GameClock.inl.hxx
Go to the documentation of this file.
1
#include <cassert>
2
#include "
LOG.hxx
"
3
4
template
<
typename
DelayType,
typename
PeriodType>
5
inline
GameClock::ClockTaskHndl
GameClock::addRealTimeClockTask
(
ClockCbk
cbk, DelayType delay, PeriodType period)
6
{
7
assert((cbk !=
nullptr
) && (
TimePoint
(delay) >=
TimePointZero
) && (
TimePoint
(period) >=
TimePointZero
));
8
9
std::lock_guard<std::mutex> lock(
m_lock
);
10
TimePoint
delayConverted = (
TimePoint
)delay;
11
12
// If no delay required call callback immediately
13
if
(delayConverted ==
TimePointZero
)
14
{
15
const
bool
isCanceled = cbk();
16
17
if
(isCanceled || ((
TimePoint
)period ==
TimePointZero
))
18
{
19
return
ClockTaskHndlInvalid
;
20
}
21
22
delayConverted = (
TimePoint
)period;
23
}
24
25
m_realTimeTasks
.push(
RealTimeClockTask
(cbk, Clock::now() + (delayConverted -
TimePointZero
), (
TimePoint
)period -
TimePointZero
,
26
++
m_unique_handle
));
27
return
m_unique_handle
;
28
}
GameClock::m_unique_handle
ClockTaskHndl m_unique_handle
Definition:
GameClock.hxx:135
GameClock::m_lock
std::mutex m_lock
Definition:
GameClock.hxx:133
GameClock::m_realTimeTasks
PriorityQueue< RealTimeClockTask, std::greater< RealTimeClockTask > > m_realTimeTasks
Definition:
GameClock.hxx:131
GameClock::ClockTaskHndlInvalid
static constexpr ClockTaskHndl ClockTaskHndlInvalid
Invalid task handler. In case that clock is not added.
Definition:
GameClock.hxx:107
GameClock::ClockTaskHndl
unsigned long ClockTaskHndl
Definition:
GameClock.hxx:28
GameClock::RealTimeClockTask
ClockTask< TimePoint, TimeDuration > RealTimeClockTask
Definition:
GameClock.hxx:128
LOG.hxx
GameClock::TimePoint
std::chrono::time_point< Clock > TimePoint
Definition:
GameClock.hxx:25
GameClock::TimePointZero
static constexpr TimePoint TimePointZero
Definition:
GameClock.hxx:103
GameClock::addRealTimeClockTask
GameClock::ClockTaskHndl addRealTimeClockTask(ClockCbk cbk, DelayType delay, PeriodType period=TimePointZero)
Add new real time clock task.
Definition:
GameClock.inl.hxx:5
GameClock::ClockCbk
std::function< bool(void)> ClockCbk
Definition:
GameClock.hxx:27
src
services
GameClock.inl.hxx
Generated on Sun Nov 27 2022 09:50:52 for Cytopia by
1.8.17