aboutsummaryrefslogtreecommitdiff
path: root/lib/recycler.h
diff options
context:
space:
mode:
authorvovanec <vovanec@90c681e8-e032-0410-971d-27865f9a5e38>2007-06-23 16:48:01 +0000
committervovanec <vovanec@90c681e8-e032-0410-971d-27865f9a5e38>2007-06-23 16:48:01 +0000
commit2d622fd9bcb8da9dd3f3206e296cd6a701fc9d12 (patch)
treef92135e6cb831e46336dfd4ade47e03ef3a19ac5 /lib/recycler.h
parent4b6a6720805c585c89f44fd276b3ace8670514d9 (diff)
downloadqmmp-2d622fd9bcb8da9dd3f3206e296cd6a701fc9d12.tar.gz
qmmp-2d622fd9bcb8da9dd3f3206e296cd6a701fc9d12.tar.bz2
qmmp-2d622fd9bcb8da9dd3f3206e296cd6a701fc9d12.zip
moved into qmmp dir
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@12 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'lib/recycler.h')
-rw-r--r--lib/recycler.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/recycler.h b/lib/recycler.h
new file mode 100644
index 000000000..b01742350
--- /dev/null
+++ b/lib/recycler.h
@@ -0,0 +1,49 @@
+// Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
+//
+// Use, modification and distribution is allowed without limitation,
+// warranty, or liability of any kind.
+//
+
+#ifndef __recycler_h
+#define __recycler_h
+
+#include <QMutex>
+#include <QWaitCondition>
+
+class Buffer;
+
+
+class Recycler
+{
+public:
+ Recycler(unsigned int sz); // sz = size in bytes
+ ~Recycler();
+
+ bool full() const;
+ bool empty() const;
+
+ int available() const;
+ int used() const;
+
+ Buffer *next(); // get next in queue
+ Buffer *get(); // get next in recycle
+
+ void add(); // add to queue
+ void done(); // add to recycle
+
+ void clear(); // clear queue
+
+ unsigned int size() const; // size in bytes
+
+ QMutex *mutex() { return &mtx; }
+ QWaitCondition *cond() { return &cnd; }
+
+
+private:
+ unsigned int buffer_count, add_index, done_index, current_count;
+ Buffer **buffers;
+ QMutex mtx;
+ QWaitCondition cnd;
+};
+
+#endif // __recycler_h