Phonon

packetpool.h
1/* This file is part of the KDE project
2 Copyright (C) 2007-2008 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17
18*/
19
20#ifndef PHONON_PACKETPOOL_H
21#define PHONON_PACKETPOOL_H
22
23#include "export.h"
24
25namespace Phonon
26{
27
28class Packet;
29class PacketPoolPrivate;
30/** \class PacketPool packetpool.h phonon/PacketPool
31 * \brief Class to preallocate memory.
32 *
33 * \note PacketPool and Packet are threadsafe.
34 *
35 * \author Matthias Kretz <kretz@kde.org>
36 */
37class PHONONEXPERIMENTAL_EXPORT PacketPool
38{
39 Q_DECLARE_PRIVATE(PacketPool)
40 friend class Packet;
41 public:
42 /**
43 * Allocates \p numberOfPackets packets of \p packetSize bytes each. The memory can be
44 * accessed through Packet objects.
45 */
46 PacketPool(int packetSize, int numberOfPackets);
47 /**
48 * Copy constructor. Copying is fast since the class is explicitly shared.
49 */
50 PacketPool(const PacketPool &);
51 /**
52 * Destructs this object. If this is the last reference to the pool the memory will be
53 * freed.
54 */
56 /**
57 * Assignmen operator. Copying is fast since the class is explicitly shared.
58 */
59 PacketPool &operator=(const PacketPool &);
60
61 /**
62 * Returns the packet size that was set in the constructor.
63 */
64 int packetSize() const;
65 /**
66 * Returns the number of packets that was requested in the constructor.
67 */
68 int poolSize() const;
69 /**
70 * Returns the number of packets that are still available for use.
71 */
72 int unusedPackets() const;
73
74 private:
75 PacketPoolPrivate *d_ptr;
76};
77
78} // namespace Phonon
79#endif // PHONON_PACKETPOOL_H
Class to preallocate memory.
Definition packetpool.h:38
Class to access memory preallocated by PacketPool.
Definition packet.h:39
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:53:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.