Fawkes API  Fawkes Development Version
syncpoint.h
1 /***************************************************************************
2  * syncpoint.h - SyncPoint Aspect
3  *
4  * Created: Thu Feb 19 14:31:42 2015
5  * Copyright 2015 Till Hofmann
6  *
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef _ASPECT_SYNCPOINT_H_
23 #define _ASPECT_SYNCPOINT_H_
24 
25 #include <aspect/aspect.h>
26 #include <core/threading/thread_loop_listener.h>
27 #include <syncpoint/syncpoint.h>
28 #include <syncpoint/syncpoint_manager.h>
29 
30 #include <string>
31 
32 namespace fawkes {
33 
34 class SyncPointAspect : public virtual Aspect, public ThreadLoopListener
35 {
36 public:
38  std::string identifier_in,
39  std::string identifier_out = "");
40  SyncPointAspect(std::string out_identifier);
41  virtual ~SyncPointAspect();
42 
43  void init_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager);
44  void finalize_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager);
45 
46  void pre_loop(Thread *thread);
47  void post_loop(Thread *thread);
48 
49 private:
50  SyncPoint::WakeupType type_in_;
51  std::string identifier_in_;
52  std::string identifier_out_;
53  bool has_input_syncpoint_;
54  bool has_output_syncpoint_;
55  RefPtr<SyncPoint> sp_in_;
56  RefPtr<SyncPoint> sp_out_;
57 };
58 
59 } // end namespace fawkes
60 
61 #endif
fawkes::SyncPoint::WakeupType
WakeupType
Type to define when a thread wakes up after waiting for a SyncPoint.
Definition: syncpoint.h:56
fawkes::SyncPointManager
This class gives access to SyncPoints.
Definition: syncpoint_manager.h:38
fawkes::RefPtr< SyncPoint >
fawkes::SyncPointAspect::post_loop
void post_loop(Thread *thread)
Emit the output syncpoint after loop()
Definition: syncpoint.cpp:140
fawkes::ThreadLoopListener
Thread loop listener interface.
Definition: thread_loop_listener.h:32
fawkes::SyncPointAspect::finalize_SyncPointAspect
void finalize_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager)
Finalize SyncPoint aspect.
Definition: syncpoint.cpp:109
fawkes
Fawkes library namespace.
fawkes::Aspect
Fawkes aspect base class.
Definition: aspect.h:32
fawkes::SyncPointAspect::SyncPointAspect
SyncPointAspect(SyncPoint::WakeupType type_in, std::string identifier_in, std::string identifier_out="")
Constructor.
Definition: syncpoint.cpp:43
fawkes::SyncPointAspect::~SyncPointAspect
virtual ~SyncPointAspect()
Destructor.
Definition: syncpoint.cpp:75
fawkes::Thread
Thread class encapsulation of pthreads.
Definition: thread.h:46
fawkes::SyncPointAspect::init_SyncPointAspect
void init_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager)
Init SyncPoint aspect.
Definition: syncpoint.cpp:87
fawkes::SyncPointAspect::pre_loop
void pre_loop(Thread *thread)
Wait for the input syncpoint before loop()
Definition: syncpoint.cpp:129
fawkes::SyncPointAspect
Thread aspect to acces to SyncPoints Give this aspect to your thread to manage SyncPoints,...
Definition: syncpoint.h:35