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 IdleEvent inline non-template implementation */
17 #include "IdleEvent.ih"
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::scheduler::IdleEvent
28 prefix_ senf::scheduler::IdleEvent::IdleEvent(std::string const & name, Callback const & cb,
29 bool initiallyEnabled)
30 : detail::FIFORunner::TaskInfo(name), cb_ (cb)
36 prefix_ senf::scheduler::IdleEvent::~IdleEvent()
38 if (detail::IdleEventDispatcher::alive())
42 prefix_ void senf::scheduler::IdleEvent::disable()
45 detail::IdleEventDispatcher::instance().remove(*this);
48 prefix_ void senf::scheduler::IdleEvent::enable()
51 detail::IdleEventDispatcher::instance().add(*this);
56 prefix_ void senf::scheduler::IdleEvent::action(Callback const & cb)
61 //-/////////////////////////////////////////////////////////////////////////////////////////////////
62 // senf::scheduler::detail::IdleEventDispatcher
64 prefix_ void senf::scheduler::detail::IdleEventDispatcher::add(IdleEvent & event)
66 events_.push_back(event);
67 FIFORunner::instance().enqueue(&event);
68 detail::FileDispatcher::instance().timeout(0);
71 prefix_ void senf::scheduler::detail::IdleEventDispatcher::timeout(int t)
75 detail::FileDispatcher::instance().timeout(managerTimeout_);
78 prefix_ int senf::scheduler::detail::IdleEventDispatcher::timeout()
81 return managerTimeout_;
84 prefix_ bool senf::scheduler::detail::IdleEventDispatcher::empty()
87 return events_.empty();
90 prefix_ senf::scheduler::detail::IdleEventDispatcher::IdleEventDispatcher()
91 : managerTimeout_ (scheduler::detail::FileDispatcher::instance().timeout())
94 //-/////////////////////////////////////////////////////////////////////////////////////////////////
101 // comment-column: 40
102 // c-file-style: "senf"
103 // indent-tabs-mode: nil
104 // ispell-local-dictionary: "american"
105 // compile-command: "scons -u test"