Scheduler.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Scheduler inline non-template implementation
16  */
17 
18 //#include "Scheduler.ih"
19 
20 // Custom includes
21 #include <boost/format.hpp>
22 
23 #define prefix_ inline
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 // public members
27 
28 prefix_ senf::ClockService::clock_type const & senf::scheduler::eventTime()
29 {
30  return scheduler::detail::FdManager::instance().eventTime();
31 }
32 
33 prefix_ senf::ClockService::clock_type const & senf::scheduler::now()
34 {
35  return scheduler::detail::FdManager::instance().eventTime();
36 }
37 
38 prefix_ senf::ClockService::clock_type senf::scheduler::nowDiff(ClockService::clock_type const & older)
39 {
40  return now() - older;
41 }
42 
43 prefix_ senf::CyclicTimestamp const & senf::scheduler::eventTimestamp()
44 {
45  return scheduler::detail::FdManager::instance().eventTimestamp();
46 }
47 
48 prefix_ void senf::scheduler::watchdogCallback(detail::FIFORunner::WatchdogCallback const & cb)
49 {
50  scheduler::detail::FIFORunner::instance().watchdogCallback(cb);
51 }
52 
53 prefix_ void senf::scheduler::watchdogTimeout(unsigned ms)
54 {
55  scheduler::detail::FIFORunner::instance().taskTimeout(ms);
56 }
57 
58 prefix_ unsigned senf::scheduler::watchdogTimeout()
59 {
60  return scheduler::detail::FIFORunner::instance().taskTimeout();
61 }
62 
63 prefix_ unsigned senf::scheduler::watchdogEvents()
64 {
65  return scheduler::detail::FIFORunner::instance().hangCount();
66 }
67 
68 prefix_ void senf::scheduler::watchdogAbort(bool flag)
69 {
70  scheduler::detail::FIFORunner::instance().abortOnTimeout(flag);
71 }
72 
73 prefix_ bool senf::scheduler::watchdogAbort()
74 {
75  return scheduler::detail::FIFORunner::instance().abortOnTimeout();
76 }
77 
78 prefix_ void senf::scheduler::loresTimers()
79 {
80  detail::TimerDispatcher::instance().timerSource(
81  std::unique_ptr<detail::TimerSource>(new detail::PollTimerSource()));
82 }
83 
84 prefix_ bool senf::scheduler::haveScalableHiresTimers()
85 {
86 #ifndef HAVE_TIMERFD_CREATE
87  return false;
88 #else
89  return detail::TimerFDTimerSource::haveTimerFD();
90 #endif
91 }
92 
93 prefix_ bool senf::scheduler::usingHiresTimers()
94 {
95  return dynamic_cast<detail::PollTimerSource*>(
96  detail::TimerDispatcher::instance().timerSource()) == nullptr;
97 }
98 
99 
100 //-/////////////////////////////////////////////////////////////////////////////////////////////////
101 // senf::scheduler::BlockSignals
102 
103 prefix_ senf::scheduler::BlockSignals::~BlockSignals()
104 {
105  unblock();
106 }
107 
108 prefix_ bool senf::scheduler::BlockSignals::blocked()
109  const
110 {
111  return blocked_;
112 }
113 
114 //-/////////////////////////////////////////////////////////////////////////////////////////////////
115 #undef prefix_
116 
117 
118 // Local Variables:
119 // mode: c++
120 // fill-column: 100
121 // c-file-style: "senf"
122 // indent-tabs-mode: nil
123 // ispell-local-dictionary: "american"
124 // compile-command: "scons -u test"
125 // comment-column: 40
126 // End: