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 EventHook inline non-template implementation */
17 #include "EventHook.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::scheduler::EventHook
27 prefix_ senf::scheduler::EventHook::EventHook(std::string const & name, Callback const & cb,
28 detail::FIFORunner::TaskInfo::Priority priority,
29 bool initiallyEnabled)
30 : detail::FIFORunner::TaskInfo(name, priority), cb_ (cb)
36 prefix_ senf::scheduler::EventHook::~EventHook()
38 if (detail::EventHookDispatcher::alive())
42 prefix_ void senf::scheduler::EventHook::disable()
44 if (detail::EventHookDispatcher::alive() && enabled())
45 detail::EventHookDispatcher::instance().remove(*this);
48 prefix_ void senf::scheduler::EventHook::enable()
50 if (detail::EventHookDispatcher::alive() && !enabled()) {
51 detail::EventHookDispatcher::instance().add(*this);
56 prefix_ void senf::scheduler::EventHook::action(Callback const & cb)
61 //-/////////////////////////////////////////////////////////////////////////////////////////////////
62 // senf::scheduler::detail::EventHookDispatcher
64 prefix_ void senf::scheduler::detail::EventHookDispatcher::add(EventHook & event)
66 events_.push_back(event);
67 FIFORunner::instance().enqueue(&event);
70 prefix_ bool senf::scheduler::detail::EventHookDispatcher::empty()
73 return events_.empty();
76 prefix_ senf::scheduler::detail::EventHookDispatcher::EventHookDispatcher()
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
87 // c-file-style: "senf"
88 // indent-tabs-mode: nil
89 // ispell-local-dictionary: "american"
90 // compile-command: "scons -u test"