icl_core_thread/Thread.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
30 //----------------------------------------------------------------------
31 #ifndef ICL_CORE_THREAD_THREAD_H_INCLUDED
32 #define ICL_CORE_THREAD_THREAD_H_INCLUDED
33 
34 #include <icl_core/BaseTypes.h>
35 #include <icl_core/Noncopyable.h>
36 #include <icl_core/TimeSpan.h>
37 #include <icl_core/TimeStamp.h>
38 #include <icl_core/os_thread.h>
39 
41 #include "icl_core_thread/Mutex.h"
42 
43 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
44 # include "icl_core/Deprecate.h"
45 #endif
46 
47 namespace icl_core {
48 namespace thread {
49 
50 class ThreadImpl;
51 
78 {
79 public:
83  Thread(const icl_core::String& description, icl_core::ThreadPriority priority = 0);
84 
87  virtual ~Thread();
88 
96  void cancel();
97 
105  bool checkHardRealtime();
106 
109  icl_core::String getDescription() const;
110 
117  bool execute() const { return m_execute; }
118 
121  bool isHardRealtime() const;
122 
126  bool executesHardRealtime() const;
127 
131  void join();
132 
135  icl_core::ThreadPriority priority() const;
136 
141  virtual void onStop() { }
142 
149  virtual void run() = 0;
150 
153  bool running() const { return !m_finished; }
154 
161  void setDescription(const icl_core::String& description);
162 
168  bool setHardRealtime(bool hard_realtime = true);
169 
175  bool setPriority(icl_core::ThreadPriority priority);
176 
182  bool start();
183 
189  void stop() { waitStarted(); m_execute = false; }
190 
193  icl_core::ThreadId threadId() const;
194 
199  const char *threadInfo() const { return m_thread_info.c_str(); }
200 
204  bool threadSelf() const
205  {
206  waitStarted();
207  return icl_core::os::threadSelf() == threadId();
208  }
209 
214  bool wait();
215 
222  bool wait(const icl_core::TimeStamp& timeout);
223 
230  bool wait(const icl_core::TimeSpan& timeout);
231 
235 
237 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
238 
248 
253 
258 
264 
268  ICL_CORE_VC_DEPRECATE_STYLE bool IsHardRealtime() const ICL_CORE_GCC_DEPRECATE_STYLE;
269 
274  ICL_CORE_VC_DEPRECATE_STYLE bool ExecutesHardRealtime() const
276 
281 
287 
292 
296  ICL_CORE_VC_DEPRECATE_STYLE void SetDescription(const icl_core::String& description)
298 
302  ICL_CORE_VC_DEPRECATE_STYLE bool SetHardRealtime(bool hard_realtime = true)
304 
308  ICL_CORE_VC_DEPRECATE_STYLE bool SetPriority(icl_core::ThreadPriority priority)
310 
315 
320 
325 
330  ICL_CORE_VC_DEPRECATE_STYLE const char *ThreadInfo() const ICL_CORE_GCC_DEPRECATE_STYLE;
331 
337 
342 
347  ICL_CORE_VC_DEPRECATE_STYLE bool Wait(const icl_core::TimeStamp& timeout)
349 
354  ICL_CORE_VC_DEPRECATE_STYLE bool Wait(const icl_core::TimeSpan& timeout)
356 
362 
363 #endif
364 
366 private:
371  virtual void makePeriodic();
372 
376  void runThread();
377 
380  void waitStarted() const;
381 
383 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
384 
389 
394 
395 #endif
396 
398  bool m_execute;
400  bool m_joined;
402 
405 
407 
409 
410  // Declare thread implementations as friends so that they have
411  // access to the runThread() function!
412  friend class ThreadImplLxrt33;
413  friend class ThreadImplLxrt35;
414  friend class ThreadImplLxrt38;
415  friend class ThreadImplPosix;
416  friend class ThreadImplWin32;
417 };
418 
419 }
420 }
421 
422 #endif
ICL_CORE_OS_IMPL_NS::ThreadId ThreadId
Definition: os_thread.h:49
static icl_core::ThreadId selfId()
icl_core::ThreadPriority m_priority
Represents absolute times.
Definition: TimeStamp.h:61
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
Contains macros to deprecate classes, types, functions and variables.
Contains import/export definitions for the Win32 plattform.
String join(const std::vector< String > &substrings, const String &delimiter)
Contains global thread related functions, encapsulated into the icl_core::os namespace.
#define ICL_CORE_THREAD_IMPORT_EXPORT
const TimeSpan timeout(1, 0)
Contains icl_core::thread::Mutex.
Repesents absolute times.
Definition: TimeSpan.h:46
std::string String
Definition: BaseTypes.h:43
Contains Interface base classes and base types.
ThreadId threadSelf()
Definition: os_thread.h:54
const char * threadInfo() const
Contains TimeStamp.
Contains icl_core::Noncopyable.
int32_t ThreadPriority
Definition: os_thread.h:50
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58