1 | /* This file is part of the KDE project |
2 | Copyright (C) 2008 Matthias Kretz <kretz@kde.org> |
3 | |
4 | This program is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) version 3. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | |
19 | */ |
20 | |
21 | |
22 | #ifndef PHONON_PACKETPOOL_P_H |
23 | #define PHONON_PACKETPOOL_P_H |
24 | |
25 | #include <QAtomicInt> |
26 | |
27 | namespace Phonon |
28 | { |
29 | |
30 | class PacketPrivate; |
31 | class PacketPoolPrivate |
32 | { |
33 | friend class PacketPool; |
34 | friend class Packet; |
35 | public: |
36 | ~PacketPoolPrivate(); |
37 | |
38 | Packet acquirePacket(); |
39 | void releasePacket(const Packet &); |
40 | |
41 | protected: |
42 | QAtomicInt ref; |
43 | |
44 | private: |
45 | PacketPoolPrivate(int packetSize, int _poolSize); |
46 | |
47 | // C-array of PacketPrivate* |
48 | PacketPrivate **freePackets; |
49 | char *const packetMemory; |
50 | |
51 | QAtomicInt readPosition; |
52 | QAtomicInt writePosition; |
53 | QAtomicInt ringBufferSize; |
54 | |
55 | const int packetSize; |
56 | const int poolSize; |
57 | }; |
58 | |
59 | } // namespace Phonon |
60 | |
61 | #endif // PHONON_PACKETPOOL_P_H |
62 | |