Socket: Ignore ECONNREFUSED on write to datagram socket
[senf.git] / PPI / Queueing.hh
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20
21 /** \file
22     \brief Queueing public header */
23
24 #ifndef HH_Queueing_
25 #define HH_Queueing_ 1
26
27 // Custom includes
28 #include "predecl.hh"
29
30 //#include "Queueing.mpp"
31 ///////////////////////////////hh.p////////////////////////////////////////
32
33 namespace senf {
34 namespace ppi {
35
36     /** \brief Queueing discipline base class
37
38         QueueingDescipline derived classes define the generation of throttling notifications. The
39         QueueingDiscipline is called whenever the packets are entered or removed from the queue. The
40         queueing discipline then determines the new throttling state of the queue.
41
42         \note The QueueingDiscipline will \e never drop packets explicitly. This is left to the
43         operating system by sending throttling events. The PPI will never loose a packet internally
44         (if not a module explicitly does so), however it may disable reception of new incoming
45         packets which will then probably be dropped by the operating system.
46
47         \attention Notifications may be forwarded to the QueueingDiscipline implementation
48             out-of-order: A dequeue event may be notified before the corresponding enqueue
49             event (this happens to optimize away transient throttling state changes which would
50             otherwise occur if a packet is entered into the queue and then removed from it in the
51             same processing step).
52      */
53     class QueueingDiscipline
54     {
55     public:
56         virtual ~QueueingDiscipline();
57
58         enum Event { ENQUEUE, DEQUEUE }; ///< Possible queueing events
59         
60         virtual void update(connector::PassiveInput & input, Event event) = 0;
61                                         ///< Calculate new queueing state
62                                         /**< Whenever the queue is manipulated, this member is
63                                              called to calculate the new throttling state. The
64                                              member must call \a input's \c throttle() or \c
65                                              unthrottle() member to set the new throttling state.
66                                              
67                                              \param[in] input Connector holding the queue
68                                              \param[in] event Type of event triggering the update */
69     };
70
71     /** \brief Simple queueing discipline with high and low threshold
72
73         The ThresholdQueueing QueueingDiscipline is a simple queueing discipline which throttles the
74         input as soon the number of packets in the queue reaches the \a high threshold. The input
75         will be unthrottled when the number of packets drops to the \a low threshold. 
76
77         The default queueing discipline is ThresholdQueueing(1,0).
78      */
79     class ThresholdQueueing
80         : public QueueingDiscipline
81     {
82     public:
83         ThresholdQueueing(unsigned high, unsigned low);
84
85         virtual void update(connector::PassiveInput & input, Event event);
86
87     private:
88         unsigned high_;
89         unsigned low_;
90     };
91
92 }}
93
94 ///////////////////////////////hh.e////////////////////////////////////////
95 #include "Queueing.cci"
96 //#include "Queueing.ct"
97 //#include "Queueing.cti"
98 #endif
99
100 \f
101 // Local Variables:
102 // mode: c++
103 // fill-column: 100
104 // c-file-style: "senf"
105 // indent-tabs-mode: nil
106 // ispell-local-dictionary: "american"
107 // compile-command: "scons -u test"
108 // comment-column: 40
109 // End: