QueueSocketSourceSink.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 QueueSocketSourceSink inline template implementation */
16 
17 #include "QueueSocketSourceSink.ih"
18 
19 // Custom includes
20 #include <senf/Utils/membind.hh>
21 #include <senf/Packets/PacketInfo.hh>
22 #include "SocketSource.hh"
23 
24 #define prefix_ inline
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 // senf::ppi::module::ActiveQueueSocketSource<Packet>
29 
30 template <class Packet, class Connector>
31 prefix_ unsigned senf::ppi::module::ActiveQueueSocketSource<Packet,Connector>::maxBurst()
32  const
33 {
34  return maxBurst_;
35 }
36 
37 template <class Packet, class Connector>
38 prefix_ void senf::ppi::module::ActiveQueueSocketSource<Packet,Connector>::maxBurst(unsigned burst)
39 {
40  maxBurst_ = std::max(burst, 1u);
41 }
42 
43 template <class Packet, class Connector>
44 prefix_ void senf::ppi::module::ActiveQueueSocketSource<Packet,Connector>::flush()
45 {
46  if (burst_ == 0) { // not in read() loop
47  if(handle_) {
48  while (handle_.dequeue());
49  handle_.release();
50  }
51  } else {
52  flushPending_ = true;
53  }
54 }
55 
56 //-/////////////////////////////////////////////////////////////////////////////////////////////////
57 // senf::ppi::module::PassiveQueueSocketSink
58 
59 template <class Connector>
60 prefix_ void senf::ppi::module::PassiveQueueSocketSink<Connector>::flush()
61 {
62  QueueWritePolicy::flush(handle_);
63  eventHook_.disable();
64  writeEvent_.enabled(false);
65 }
66 
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 #undef prefix_
69 
70 
71 // Local Variables:
72 // mode: c++
73 // fill-column: 100
74 // comment-column: 40
75 // c-file-style: "senf"
76 // indent-tabs-mode: nil
77 // ispell-local-dictionary: "american"
78 // compile-command: "scons -u test"
79 // End: