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 internal header */
17 #ifndef IH_SENF_Scheduler_TimerEvent_
18 #define IH_SENF_Scheduler_TimerEvent_ 1
21 #include <boost/scoped_ptr.hpp>
22 #include <boost/intrusive/set.hpp>
23 #include "TimerSource.hh"
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
34 struct TimerSetCompare {
35 bool operator()(TimerEvent const & a, TimerEvent const & b) const
36 { return a.timeout_ < b.timeout_; }
40 : public singleton<TimerDispatcher>
42 SENF_LOG_CLASS_AREA();
45 using singleton<TimerDispatcher>::instance;
46 using singleton<TimerDispatcher>::alive;
48 void add(TimerEvent & event);
49 void remove(TimerEvent & event);
59 void timerSource(std::unique_ptr<TimerSource> timerSource);
60 TimerSource * timerSource();
68 typedef boost::intrusive::multiset< TimerEvent,
69 boost::intrusive::constant_time_size<false>,
70 boost::intrusive::compare<TimerSetCompare>,
71 boost::intrusive::base_hook<TimerSetBase> > TimerSet;
75 boost::scoped_ptr<TimerSource> source_;
77 friend void senf::scheduler::restart();
78 friend class singleton<TimerDispatcher>;
83 //-/////////////////////////////////////////////////////////////////////////////////////////////////
91 // c-file-style: "senf"
92 // indent-tabs-mode: nil
93 // ispell-local-dictionary: "american"
94 // compile-command: "scons -u test"