EventHook.cc
Go to the documentation of this file.
1 //
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
6 //
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
11 //
12 
13 
17 #include "EventHook.hh"
18 #include "EventHook.ih"
19 
20 // Custom includes
21 
22 //#include "EventHook.mpp"
23 #define prefix_
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 
26 //-/////////////////////////////////////////////////////////////////////////////////////////////////
27 // senf::scheduler::EventHook
28 
29 prefix_ void senf::scheduler::EventHook::v_run()
30 {
31  cb_();
32 }
33 
34 prefix_ char const * senf::scheduler::EventHook::v_type()
35  const
36 {
37  return "ee";
38 }
39 
40 prefix_ std::string senf::scheduler::EventHook::v_info()
41  const
42 {
43  return "";
44 }
45 
46 //-/////////////////////////////////////////////////////////////////////////////////////////////////
47 // senf::scheduler::detail::EventHookDispatcher
48 
49 prefix_ senf::scheduler::detail::EventHookDispatcher::~EventHookDispatcher()
50 {
51  for (EventList::iterator i (events_.begin()); i != events_.end(); ++i)
52  FIFORunner::instance().dequeue(&(*i));
53 }
54 
55 prefix_ prefix_ void senf::scheduler::detail::EventHookDispatcher::remove(EventHook & event)
56 {
57  EventList::iterator i (EventList::s_iterator_to(event));
58  if (i == events_.end())
59  return;
60  FIFORunner::instance().dequeue(&event);
61  events_.erase(i);
62 }
63 
64 prefix_ void senf::scheduler::detail::EventHookDispatcher::prepareRun()
65 {
66  for (EventList::iterator i (events_.begin()); i != events_.end(); ++i)
67  i->setRunnable();
68 }
69 
70 
71 //-/////////////////////////////////////////////////////////////////////////////////////////////////
72 #undef prefix_
73 //#include "EventHook.mpp"
74 
75 
76 // Local Variables:
77 // mode: c++
78 // fill-column: 100
79 // comment-column: 40
80 // c-file-style: "senf"
81 // indent-tabs-mode: nil
82 // ispell-local-dictionary: "american"
83 // compile-command: "scons -u test"
84 // End:
EventHook public header.
#define prefix_
Definition: EventHook.cc:23
EventHook(std::string const &name, Callback const &cb, Priority priority, bool initiallyEnabled=true)
Register an event hook.