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
32namespace fawkes {
33
34class SyncPointAspect : public virtual Aspect, public ThreadLoopListener
35{
36public:
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
49private:
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 aspect base class.
Definition: aspect.h:32
Thread aspect to acces to SyncPoints Give this aspect to your thread to manage SyncPoints,...
Definition: syncpoint.h:35
void init_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager)
Init SyncPoint aspect.
Definition: syncpoint.cpp:87
void pre_loop(Thread *thread)
Wait for the input syncpoint before loop()
Definition: syncpoint.cpp:129
void finalize_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager)
Finalize SyncPoint aspect.
Definition: syncpoint.cpp:109
void post_loop(Thread *thread)
Emit the output syncpoint after loop()
Definition: syncpoint.cpp:140
SyncPointAspect(SyncPoint::WakeupType type_in, std::string identifier_in, std::string identifier_out="")
Constructor.
Definition: syncpoint.cpp:43
virtual ~SyncPointAspect()
Destructor.
Definition: syncpoint.cpp:75
This class gives access to SyncPoints.
WakeupType
Type to define when a thread wakes up after waiting for a SyncPoint.
Definition: syncpoint.h:56
Thread loop listener interface.
Thread class encapsulation of pthreads.
Definition: thread.h:46
Fawkes library namespace.