Midge
v3.9.2
Data Processing Framework
library
utility
instructable.hh
Go to the documentation of this file.
1
/*
2
* instructable.hh
3
*
4
* Created on: Feb 4, 2016
5
* Author: nsoblath
6
*/
7
8
#ifndef MIDGE_INSTRUCTABLE_HH_
9
#define MIDGE_INSTRUCTABLE_HH_
10
11
#include <atomic>
12
#include <mutex>
13
14
namespace
midge
15
{
16
17
enum class
instruction
18
{
19
carry_on
,
20
pause
,
21
resume
,
22
none
23
};
24
25
class
instructable
26
{
27
public
:
28
instructable
();
29
virtual
~
instructable
();
30
31
public
:
32
void
instruct(
instruction
t_inst );
33
34
protected
:
35
instruction
use_instruction();
36
bool
have_instruction()
const
;
37
38
private
:
39
mutable
std::mutex
f_mutex
;
40
instruction
f_instruction
;
41
bool
f_have_instruction
;
42
43
};
44
45
inline
bool
instructable::have_instruction
()
const
46
{
47
std::unique_lock< std::mutex > t_lock( f_mutex );
48
return
f_have_instruction;
49
}
50
51
inline
void
instructable::instruct
(
instruction
a_inst )
52
{
53
std::unique_lock< std::mutex > t_lock( f_mutex );
54
f_instruction = a_inst;
55
f_have_instruction =
true
;
56
return
;
57
}
58
59
60
61
}
/* namespace midge */
62
63
#endif
/* MIDGE_INSTRUCTABLE_HH_ */
midge::instruction
instruction
Definition:
instructable.hh:17
midge
Definition:
_buffer.hh:11
midge::instruction::carry_on
midge::instructable::f_mutex
std::mutex f_mutex
Definition:
instructable.hh:39
midge::instruction::none
midge::instructable
Definition:
instructable.hh:25
midge::instructable::have_instruction
bool have_instruction() const
Definition:
instructable.hh:45
midge::instruction::resume
midge::instructable::instruct
void instruct(instruction t_inst)
Definition:
instructable.hh:51
midge::instructable::f_instruction
instruction f_instruction
Definition:
instructable.hh:40
midge::instructable::f_have_instruction
bool f_have_instruction
Definition:
instructable.hh:41
midge::instruction::pause
Generated by
1.8.13