Fawkes API
Fawkes Development Version
test_thread.cpp
1
/***************************************************************************
2
* test_thread.cpp - Thread to test SyncPoints
3
*
4
* Created: Thu Mar 05 15:15:42 2015
5
* Copyright 2015 Till Hofmann
6
****************************************************************************/
7
8
/* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Library General Public License for more details.
17
*
18
* Read the full text in the LICENSE.GPL file in the doc directory.
19
*/
20
21
#include "test_thread.h"
22
23
#include <stdlib.h>
24
#include <unistd.h>
25
26
using namespace
fawkes
;
27
28
/** @class SyncPointTestThread "test_thread.h"
29
* Thread to test SyncPoints.
30
* This thread has the blocked timing aspect and belongs to a wakeup hook.
31
* It simply prints its name.
32
* @author Till Hofmann
33
*/
34
35
/** Constructor.
36
* @param name the name of the thread
37
* @param hook the hook this thread belongs to
38
*/
39
40
SyncPointTestThread::SyncPointTestThread
(
const
char
*name,
BlockedTimingAspect::WakeupHook
hook)
41
:
Thread
(name,
Thread
::OPMODE_WAITFORWAKEUP),
BlockedTimingAspect
(hook), hook_(hook)
42
{
43
}
44
45
void
46
SyncPointTestThread::init
()
47
{
48
}
49
50
void
51
SyncPointTestThread::finalize
()
52
{
53
}
54
55
void
56
SyncPointTestThread::loop
()
57
{
58
usleep(random() % 100000);
59
logger
->
log_info
(
"SyncPointTestThread"
,
60
"In hook %s"
,
61
BlockedTimingAspect::blocked_timing_hook_to_string(hook_));
62
}
SyncPointTestThread::init
virtual void init()
Initialize the thread.
Definition:
test_thread.cpp:46
fawkes::Logger::log_info
virtual void log_info(const char *component, const char *format,...)=0
fawkes::BlockedTimingAspect
Definition:
blocked_timing.h:56
fawkes::LoggingAspect::logger
Logger * logger
Definition:
logging.h:53
fawkes
SyncPointTestThread::SyncPointTestThread
SyncPointTestThread(const char *name, BlockedTimingAspect::WakeupHook hook)
Constructor.
Definition:
test_thread.cpp:40
fawkes::BlockedTimingAspect::WakeupHook
WakeupHook
Type to define at which hook the thread is woken up.
Definition:
blocked_timing.h:64
SyncPointTestThread::loop
virtual void loop()
Code to execute in the thread.
Definition:
test_thread.cpp:56
fawkes::Thread
Definition:
thread.h:45
SyncPointTestThread::finalize
virtual void finalize()
Finalize the thread.
Definition:
test_thread.cpp:51
src
plugins
syncpoint-test
test_thread.cpp
Generated by
1.8.17