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