Midge  v3.9.2
Data Processing Framework
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 
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;
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_ */
Definition: _buffer.hh:11
bool have_instruction() const
Definition: instructable.hh:45
void instruct(instruction t_inst)
Definition: instructable.hh:51
instruction f_instruction
Definition: instructable.hh:40