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 
41 : Thread(name, Thread::OPMODE_WAITFORWAKEUP), BlockedTimingAspect(hook), hook_(hook)
42 {
43 }
44 
45 void
47 {
48 }
49 
50 void
52 {
53 }
54 
55 void
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:45
fawkes::Logger::log_info
virtual void log_info(const char *component, const char *format,...)=0
fawkes::BlockedTimingAspect
Definition: blocked_timing.h:54
fawkes::LoggingAspect::logger
Logger * logger
Definition: logging.h:50
fawkes
SyncPointTestThread::SyncPointTestThread
SyncPointTestThread(const char *name, BlockedTimingAspect::WakeupHook hook)
Constructor.
Definition: test_thread.cpp:39
fawkes::BlockedTimingAspect::WakeupHook
WakeupHook
Type to define at which hook the thread is woken up.
Definition: blocked_timing.h:62
SyncPointTestThread::loop
virtual void loop()
Code to execute in the thread.
Definition: test_thread.cpp:55
fawkes::Thread
Definition: thread.h:44
SyncPointTestThread::finalize
virtual void finalize()
Finalize the thread.
Definition: test_thread.cpp:50