Poller.cti
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 Poller inline template implementation */
16 
17 //#include "Poller.ih"
18 
19 // Custom includes
20 #include <unistd.h>
21 
22 #define prefix_ inline
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 template <class Value>
26 prefix_ senf::scheduler::detail::Poller<Value>::Poller()
27  : timeout_ (-1)
28 {
29  epollFd_ = epoll_create(NumEvents);
30  if (epollFd_ == -1)
31  throw senf::SystemException("epoll_create");
32 }
33 
34 template <class Value>
35 prefix_ senf::scheduler::detail::Poller<Value>::~Poller()
36 {
37  close(epollFd_);
38 }
39 
40 template <class Value>
41 prefix_ void senf::scheduler::detail::Poller<Value>::timeout(int t)
42 {
43  timeout_ = t;
44 }
45 
46 template <class Value>
47 prefix_ int senf::scheduler::detail::Poller<Value>::timeout()
48  const
49 {
50  return timeout_;
51 }
52 
53 template <class Value>
54 prefix_ typename senf::scheduler::detail::Poller<Value>::GetPollResult::result_type
55 senf::scheduler::detail::Poller<Value>::GetPollResult::operator()(epoll_event const & ev)
56  const
57 {
58  return std::make_pair(ev.events, static_cast<Value*>(ev.data.ptr));
59 }
60 
61 //-/////////////////////////////////////////////////////////////////////////////////////////////////
62 #undef prefix_
63 
64 
65 // Local Variables:
66 // mode: c++
67 // fill-column: 100
68 // comment-column: 40
69 // c-file-style: "senf"
70 // indent-tabs-mode: nil
71 // ispell-local-dictionary: "american"
72 // compile-command: "scons -u test"
73 // End: