reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
ProducerFifoBuffer.hxx
Go to the documentation of this file.
1#ifndef ProducerFifoBuffer_Include_Guard
2#define ProducerFifoBuffer_Include_Guard
3
4#include "rutil/Fifo.hxx"
5
6namespace resip
7{
8
15template<typename T>
17{
18 public:
20 size_t bufferSize) :
21 mFifo(fifo),
22 mBufferSize(bufferSize)
23 {}
24
26 {
27 flush();
28 }
29
30 void add(T* msg)
31 {
32 mBuffer.push_back(msg);
34 {
35 flush();
36 }
37 }
38
39 void flush()
40 {
41 if(mBuffer.size() > 0)
42 {
44 }
45 }
46
47 inline size_t getBufferSize() const
48 {return mBufferSize;}
49
50 inline void setBufferSize(size_t pBufferSize)
51 {
52 mBufferSize = pBufferSize;
54 {
55 flush();
56 }
57 }
58
59 inline const Fifo<T>& getFifo() const {return mFifo;}
60 inline Fifo<T>& getFifo() {return mFifo;}
61
62 protected:
64 // The type used by AbstractFifo<T>::addMultiple()
67};
68}
69#endif
70
71
72/* ====================================================================
73 * The Vovida Software License, Version 1.0
74 *
75 * Redistribution and use in source and binary forms, with or without
76 * modification, are permitted provided that the following conditions
77 * are met:
78 *
79 * 1. Redistributions of source code must retain the above copyright
80 * notice, this list of conditions and the following disclaimer.
81 *
82 * 2. Redistributions in binary form must reproduce the above copyright
83 * notice, this list of conditions and the following disclaimer in
84 * the documentation and/or other materials provided with the
85 * distribution.
86 *
87 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
88 * and "Vovida Open Communication Application Library (VOCAL)" must
89 * not be used to endorse or promote products derived from this
90 * software without prior written permission. For written
91 * permission, please contact vocal@vovida.org.
92 *
93 * 4. Products derived from this software may not be called "VOCAL", nor
94 * may "VOCAL" appear in their name, without prior written
95 * permission of Vovida Networks, Inc.
96 *
97 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
98 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
99 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
100 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
101 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
102 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
103 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
104 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
105 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
106 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
107 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
108 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
109 * DAMAGE.
110 *
111 * ====================================================================
112 *
113 * This software consists of voluntary contributions made by Vovida
114 * Networks, Inc. and many individuals on behalf of Vovida Networks,
115 * Inc. For more information on Vovida Networks, Inc., please see
116 * <http://www.vovida.org/>.
117 *
118 */
virtual unsigned int size() const
get the current size of the fifo.
A templated, threadsafe message-queue class.
Definition Fifo.hxx:16
AbstractFifo< Msg * >::Messages Messages
Definition Fifo.hxx:30
size_t addMultiple(Messages &msgs)
Definition Fifo.hxx:115
Class for buffering messages placed in a Fifo, to be used by a single producer.
const Fifo< T > & getFifo() const
ProducerFifoBuffer(Fifo< T > &fifo, size_t bufferSize)
void setBufferSize(size_t pBufferSize)
dcm! – add UnusedChecking(_enum) below;