EventManager.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 "EventManager.hh"
18 //#include "EventManager.ih"
19 
20 // Custom includes
21 #include <boost/format.hpp>
22 #include <senf/Utils/membind.hh>
25 #include "ConsoleDir.hh"
26 #include "FIFORunner.hh"
27 
28 //#include "EventManager.mpp"
29 #define prefix_
30 //-/////////////////////////////////////////////////////////////////////////////////////////////////
31 
32 prefix_ senf::scheduler::detail::EventManager::EventManager()
33 {
34 #ifndef SENF_DISABLE_CONSOLE
35  consoleDir().add("events", console::factory::Command(
37  .doc("List all scheduler events sorted by priority\n"
38  "\n"
39  "Columns:\n"
40  " TP event type:\n"
41  " fd file descriptor\n"
42  " tm timer\n"
43  " si UNIX signal\n"
44  " ee event hook\n"
45  " NAME descriptive event name\n"
46  " ADDRESS address of event class instance\n"
47  " RUNCNT number of times, the event was called\n"
48  " S state:\n"
49  " R runnable\n"
50  " W waiting\n"
51  " - event disabled\n"
52  " INFO further event specific information")
53  );
54 #endif
55 }
56 
58 {
59  // On an 80 column display, this wraps nicely directly before the INFO column
60  boost::format fmt ("%s %-55.55s 0x%016x %8d %s %s\n");
61  os << boost::format("%s %-55.55s %-18s %8s %s %s\n")
62  % "TP" % "NAME" % "ADDRESS" % "RUNCNT" % "S" % "INFO";
63  {
66  for (; i != i_end; ++i)
67  os << fmt
68  % i->type()
69  % i->name()
70  % reinterpret_cast<unsigned long>(&(*i))
71  % i->runCount()
72  % (i->runnable() ? "R" : "W")
73  % i->info();
74  } {
75  iterator i (begin());
76  iterator const i_end (end());
77  for (; i != i_end; ++i)
78  if (! i->enabled())
79  os << fmt
80  % i->type()
81  % i->name()
82  % reinterpret_cast<unsigned long>(&(*i))
83  % i->runCount()
84  % "-"
85  % i->info();
86  }
87 }
88 
89 //-/////////////////////////////////////////////////////////////////////////////////////////////////
90 #undef prefix_
91 //#include "EventManager.mpp"
92 
93 
94 // Local Variables:
95 // mode: c++
96 // fill-column: 100
97 // comment-column: 40
98 // c-file-style: "senf"
99 // indent-tabs-mode: nil
100 // ispell-local-dictionary: "american"
101 // compile-command: "scons -u test"
102 // End:
FIFORunner public header.
boost::function< R(Args)> membind(R(T::*fn)(Args), T *ob)
boost::filter_iterator< EventManager::IteratorFilter, TaskList::const_iterator > iterator
Definition: FIFORunner.hh:83
console::ScopedDirectory & consoleDir()
Definition: ConsoleDir.cc:27
#define prefix_
Definition: EventManager.cc:29
Scheduler ConsoleDir public header.
void listEvents(std::ostream &os)
Definition: EventManager.cc:57
boost::filter_iterator< IteratorFilter, EventList::const_iterator > iterator
Definition: EventManager.hh:93
NodeType & add(std::string const &name, boost::shared_ptr< NodeType > node)