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 SignalDispatcher inline non-template implementation */
17 #include "SignalEvent.ih"
20 #include <senf/Utils/signalnames.hh>
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 prefix_ void senf::scheduler::detail::SignalDispatcher::blockSignals()
28 sigprocmask(SIG_BLOCK, &sigSet_, 0);
32 prefix_ void senf::scheduler::detail::SignalDispatcher::unblockSignals()
34 if (!blocked_) return;
35 sigprocmask(SIG_UNBLOCK, &sigSet_, 0);
39 prefix_ bool senf::scheduler::detail::SignalDispatcher::empty()
42 return handlers_.empty();
45 //-/////////////////////////////////////////////////////////////////////////////////////////////////
46 // senf::scheduler::SignalEvent
48 prefix_ senf::scheduler::SignalEvent::SignalEvent(int signal, Callback const & cb,
49 bool initiallyEnabled)
50 : detail::FIFORunner::TaskInfo(signalName(signal)), signal_ (signal), cb_ (cb)
56 prefix_ senf::scheduler::SignalEvent::~SignalEvent()
58 if (senf::scheduler::detail::SignalDispatcher::alive())
62 prefix_ void senf::scheduler::SignalEvent::disable()
64 if (detail::SignalSetBase::is_linked())
65 senf::scheduler::detail::SignalDispatcher::instance().remove(*this);
68 prefix_ void senf::scheduler::SignalEvent::enable()
70 if (! detail::SignalSetBase::is_linked())
71 senf::scheduler::detail::SignalDispatcher::instance().add(*this);
74 prefix_ void senf::scheduler::SignalEvent::action(Callback const & cb)
79 //-/////////////////////////////////////////////////////////////////////////////////////////////////
87 // c-file-style: "senf"
88 // indent-tabs-mode: nil
89 // ispell-local-dictionary: "american"
90 // compile-command: "scons -u test"