jle_cpp_tk
0.0 2015-04-03 sh1:"d699093732dd5f321606d0ff7a6b63b229f1922c"
A small, safe, selft contained, soft-realtime C++ toolkit
Main Page
Namespaces
Classes
Files
Examples
File List
timer.h
1
#ifndef JLE_TIMER_H
2
#define JLE_TIMER_H
3
4
5
#include <thread>
6
7
#include "core/chrono.h"
8
#include "core/signal_slot.hpp"
9
10
11
12
#define JLE_TIMER_FUNCT(__DURATION__, __FUNCTION__ ) \
13
jle::timer::internal::register_timer(__DURATION__, -1).connect(__FUNCTION__);
14
15
16
#define JLE_TIMER_METHOD(__DURATION__, __INSTANCE__, __METHOD_NAME__ ) \
17
JLE_CONNECT_METHOD(jle::timer::internal::register_timer(__DURATION__, -1), __INSTANCE__, __METHOD_NAME__)
18
19
20
#define JLE_TIMER_THIS(__DURATION__, __METHOD_NAME__ ) \
21
JLE_CONNECT_THIS(jle::timer::internal::register_timer(__DURATION__, -1), __METHOD_NAME__)
22
23
24
#define JLE_ONE_SHOOT_FUNCT(__DURATION__, __FUNCTION__ ) \
25
jle::timer::internal::register_timer(__DURATION__, 1).connect(__FUNCTION__);
26
27
28
#define JLE_ONE_SHOOT_METHOD(__DURATION__, __INSTANCE__, __METHOD_NAME__ ) \
29
JLE_CONNECT_METHOD(jle::timer::internal::register_timer(__DURATION__, 1), __INSTANCE__, __METHOD_NAME__)
30
31
32
#define JLE_ONE_SHOOT_THIS(__DURATION__, __METHOD_NAME__ ) \
33
JLE_CONNECT_THIS(jle::timer::internal::register_timer(__DURATION__, 1), __METHOD_NAME__)
34
35
36
38
39
40
41
42
namespace
jle
{
43
namespace
timer {
44
45
46
void
start_main_loop();
47
void
stop_main_loop();
48
49
51
bool
& get_sref_stopping(
void
);
52
53
54
55
namespace
internal {
56
57
jle::signal<>
& register_timer(
const
jle::chrono::duration
& dur,
int
call_times);
58
59
struct
Timer :
jle::signal_receptor
{
60
explicit
Timer(
const
jle::chrono::time_point
& _last_call,
61
const
jle::chrono::duration
& _interval,
62
int
_call_times);
63
Timer() =
delete
;
64
Timer(
const
Timer&) =
delete
;
65
66
67
jle::chrono::time_point
last_call;
68
jle::chrono::duration
interval;
69
int
call_times;
70
71
jle::signal<>
signal;
72
73
void
on_global_timer(
void
);
74
};
75
76
77
};
// namespace internal {
78
};
// namespace timer {
79
};
//namespace jle {
80
81
#endif // JLE_TIMER_H
jle::chrono::time_point
similar to std::chrono::time_point but monotonic with adjustments to system_clock ...
Definition:
chrono.h:42
jle::signal_receptor
Any object connected to signals, has to inherit from signal_receptor.
Definition:
signal_slot.hpp:87
jle::signal
signal instance to connect and emit
Definition:
signal_slot.hpp:232
jle::chrono::duration
Definition:
chrono.h:22
jle
generic namespace
Definition:
alarm.cpp:12
src
core
timer.h
Generated on Wed Mar 16 2016 20:34:38 for jle_cpp_tk by
1.8.11