00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026
00027
00028
00029
00030 #include <boost/format.hpp>
00031 #include <senf/Utils/membind.hh>
00032 #include <senf/Utils/Console/ScopedDirectory.hh>
00033 #include <senf/Utils/Console/ParsedCommand.hh>
00034 #include "ConsoleDir.hh"
00035 #include "FIFORunner.hh"
00036
00037
00038 #define prefix_
00039
00040
00041 prefix_ senf::scheduler::detail::EventManager::EventManager()
00042 {
00043 #ifndef SENF_DISABLE_CONSOLE
00044 consoleDir().add("events", console::factory::Command(
00045 membind(&EventManager::listEvents, this))
00046 .doc("List all scheduler events sorted by priority\n"
00047 "\n"
00048 "Columns:\n"
00049 " TP event type:\n"
00050 " fd file descriptor\n"
00051 " tm timer\n"
00052 " si UNIX signal\n"
00053 " ee event hook\n"
00054 " NAME descriptive event name\n"
00055 " ADDRESS address of event class instance\n"
00056 " RUNCNT number of times, the event was called\n"
00057 " S state:\n"
00058 " R runnable\n"
00059 " W waiting\n"
00060 " - event disabled\n"
00061 " INFO further event specific information")
00062 );
00063 #endif
00064 }
00065
00066 prefix_ void senf::scheduler::detail::EventManager::listEvents(std::ostream & os)
00067 {
00068
00069 boost::format fmt ("%s %-55.55s 0x%08x %8d %s %s\n");
00070 os << boost::format("%s %-55.55s %-10s %8s %s %s\n")
00071 % "TP" % "NAME" % "ADDRESS" % "RUNCNT" % "S" % "INFO";
00072 {
00073 FIFORunner::iterator i (FIFORunner::instance().begin());
00074 FIFORunner::iterator const i_end (FIFORunner::instance().end());
00075 for (; i != i_end; ++i)
00076 os << fmt
00077 % i->type()
00078 % i->name()
00079 % reinterpret_cast<unsigned long>(&(*i))
00080 % i->runCount()
00081 % (i->runnable() ? "R" : "W")
00082 % i->info();
00083 }
00084 {
00085 iterator i (begin());
00086 iterator const i_end (end());
00087 for (; i != i_end; ++i)
00088 if (! i->enabled())
00089 os << fmt
00090 % i->type()
00091 % i->name()
00092 % reinterpret_cast<unsigned long>(&(*i))
00093 % i->runCount()
00094 % "-"
00095 % i->info();
00096 }
00097 }
00098
00099
00100 #undef prefix_
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112