FdEvent.cci
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 
14 /** \file
15  \brief FdDispatcher inline non-template implementation */
16 
17 #include "FdEvent.ih"
18 
19 // Custom includes
20 #include "FdManager.hh"
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 // senf::scheduler::FdEvent
27 
28 prefix_ senf::scheduler::FdEvent::FdEvent(std::string const & name, Callback const & cb)
29  : detail::FIFORunner::TaskInfo (name), cb_ (cb), fd_ (-1), pollable_ (true), events_ (0),
30  signaledEvents_ (0)
31 {}
32 
33 prefix_ senf::scheduler::FdEvent::~FdEvent()
34 {
35  if (detail::FdDispatcher::alive())
36  disable();
37 }
38 
39 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::action(Callback const & cb)
40 {
41  cb_ = cb;
42  return *this;
43 }
44 
45 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::addEvents(int e)
46 {
47  events( events() | e );
48  return *this;
49 }
50 
51 prefix_ senf::scheduler::FdEvent & senf::scheduler::FdEvent::removeEvents(int e)
52 {
53  events( events() & ~e );
54  return *this;
55 }
56 
57 prefix_ int senf::scheduler::FdEvent::events()
58 {
59  return events_;
60 }
61 
62 //-/////////////////////////////////////////////////////////////////////////////////////////////////
63 // senf::scheduler::detail::FdDispatcher
64 
65 prefix_ senf::scheduler::detail::FdDispatcher::FdDispatcher()
66 {}
67 
68 prefix_ bool senf::scheduler::detail::FdDispatcher::empty()
69  const
70 {
71  return fds_.empty();
72 }
73 
74 //-/////////////////////////////////////////////////////////////////////////////////////////////////
75 // senf::scheduler::detail::FileDispatcher
76 
77 prefix_ void senf::scheduler::detail::FileDispatcher::timeout(int t)
78 {
79  managerTimeout_ = t;
80  if (fds_.empty())
81  detail::FdManager::instance().timeout(managerTimeout_);
82 }
83 
84 prefix_ int senf::scheduler::detail::FileDispatcher::timeout()
85  const
86 {
87  return managerTimeout_;
88 }
89 
90 prefix_ bool senf::scheduler::detail::FileDispatcher::empty()
91  const
92 {
93  return fds_.empty();
94 }
95 
96 //-/////////////////////////////////////////////////////////////////////////////////////////////////
97 
98 prefix_ int senf::scheduler::detail::retrieve_filehandle(int fd)
99 {
100  return fd;
101 }
102 
103 //-/////////////////////////////////////////////////////////////////////////////////////////////////
104 #undef prefix_
105 
106 
107 // Local Variables:
108 // mode: c++
109 // fill-column: 100
110 // comment-column: 40
111 // c-file-style: "senf"
112 // indent-tabs-mode: nil
113 // ispell-local-dictionary: "american"
114 // compile-command: "scons -u test"
115 // End: