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
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
15 \brief TimerDispatcher inline non-template implementation */
17 #include "TimerEvent.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::scheduler::TimerEvent
27 prefix_ senf::scheduler::TimerEvent::TimerEvent(std::string const & name, Callback const & cb,
28 ClockService::clock_type timeout,
29 bool initiallyEnabled)
30 : detail::FIFORunner::TaskInfo (name), cb_ (cb), timeout_ (timeout)
36 prefix_ senf::scheduler::TimerEvent::TimerEvent(std::string const & name, Callback const & cb)
37 : detail::FIFORunner::TaskInfo (name), cb_ (cb), timeout_(ClockService::clock_type(0))
40 prefix_ senf::scheduler::TimerEvent::~TimerEvent()
42 if (detail::TimerDispatcher::alive())
46 prefix_ void senf::scheduler::TimerEvent::enable()
48 if (! detail::TimerSetBase::is_linked())
49 detail::TimerDispatcher::instance().add(*this);
52 prefix_ void senf::scheduler::TimerEvent::disable()
54 if (detail::TimerSetBase::is_linked())
55 detail::TimerDispatcher::instance().remove(*this);
58 prefix_ void senf::scheduler::TimerEvent::action(Callback const & cb)
63 prefix_ void senf::scheduler::TimerEvent::timeout(ClockService::clock_type const & timeout,
64 bool initiallyEnabled)
72 prefix_ senf::ClockService::clock_type const & senf::scheduler::TimerEvent::timeout()
78 //-/////////////////////////////////////////////////////////////////////////////////////////////////
79 // senf::scheduler::detail::TimerDispatcher
81 prefix_ void senf::scheduler::detail::TimerDispatcher::enable()
86 prefix_ void senf::scheduler::detail::TimerDispatcher::disable()
91 prefix_ bool senf::scheduler::detail::TimerDispatcher::empty()
94 return timers_.empty();
97 prefix_ void senf::scheduler::detail::TimerDispatcher::
98 timerSource(std::unique_ptr<TimerSource> timerSource)
100 source_.reset(timerSource.release());
103 prefix_ senf::scheduler::detail::TimerSource *
104 senf::scheduler::detail::TimerDispatcher::timerSource()
106 return source_.get();
109 //-/////////////////////////////////////////////////////////////////////////////////////////////////
116 // comment-column: 40
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"