Common.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 //----------------------------------------------------------------------
27 //----------------------------------------------------------------------
28 #ifndef ICL_CORE_THREAD_COMMON_H_INCLUDED
29 #define ICL_CORE_THREAD_COMMON_H_INCLUDED
30 
31 #include "icl_core/TimeSpan.h"
32 #include "icl_core/TimeStamp.h"
33 
34 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
35 # include "icl_core/Deprecate.h"
36 #endif
37 
38 namespace icl_core {
42 namespace thread {
44 namespace impl {
45 
46 inline TimeSpan getRelativeTimeout(const TimeStamp& timeout_absolute)
47 {
48  TimeStamp now = TimeStamp::now();
49  if (timeout_absolute < now)
50  {
51  return TimeSpan();
52  }
53  else
54  {
55  return timeout_absolute - now;
56  }
57 }
58 
59 inline TimeStamp getAbsoluteTimeout(const TimeSpan& timeout_relative)
60 {
61  TimeStamp timeout_absolute = TimeStamp::now();
62  if (timeout_relative < TimeSpan())
63  {
64  timeout_absolute += TimeSpan(365 * 86400, 0);
65  }
66  else
67  {
68  timeout_absolute += timeout_relative;
69  }
70  return timeout_absolute;
71 }
72 
74 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
75 
76 inline TimeSpan GetRelativeTimeout(const TimeStamp& timeout_absolute) ICL_CORE_GCC_DEPRECATE_STYLE;
77 ICL_CORE_VC_DEPRECATE_STYLE inline TimeSpan GetRelativeTimeout(const TimeStamp& timeout_absolute)
78 { return getRelativeTimeout(timeout_absolute); }
79 
80 inline TimeStamp GetAbsoluteTimeout(const TimeSpan& timeout_relative) ICL_CORE_GCC_DEPRECATE_STYLE;
81 ICL_CORE_VC_DEPRECATE_STYLE inline TimeStamp GetAbsoluteTimeout(const TimeSpan& timeout_relative)
82 { return getAbsoluteTimeout(timeout_relative); }
83 
84 #endif
85 
87 }
88 }
89 }
90 
91 #endif
TimeStamp getAbsoluteTimeout(const TimeSpan &timeout_relative)
Definition: Common.h:59
Represents absolute times.
Definition: TimeStamp.h:61
#define ICL_CORE_VC_DEPRECATE_STYLE
Definition: Deprecate.h:53
static TimeStamp now()
Definition: TimeStamp.cpp:111
Contains macros to deprecate classes, types, functions and variables.
Repesents absolute times.
Definition: TimeSpan.h:46
Contains TimeStamp.
TimeSpan getRelativeTimeout(const TimeStamp &timeout_absolute)
Definition: Common.h:46
#define ICL_CORE_GCC_DEPRECATE_STYLE
Definition: Deprecate.h:54


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