summaryrefslogtreecommitdiffstats
path: root/k9vamps/k9fifo.h
blob: efb2935cd0be59b5e9d65d0122eb538a0644483a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// C++ Interface: k9fifo
//
// Description: 
//
//
// Author: Jean-Michel PETIT <[email protected]>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef K9FIFO_H
#define K9FIFO_H

#include "k9common.h"
#include <tqmutex.h>
/**
	@author Jean-Michel PETIT <[email protected]>
*/

#define INPUT_SIZE ( 0x2000*1024)

class k9fifo {
private:
	uint32_t  head,queue;
	uchar *array;
	uint32_t m_count;
	TQMutex mutex;
public:
	k9fifo () { head=queue=m_count=0;array= new uchar[INPUT_SIZE];};
	uint32_t count(); // { return  (queue-head)%INPUT_SIZE ;}
	uint32_t freespace() {return INPUT_SIZE-count();};
	void enqueue (uchar *_buffer, uint32_t _size) ;
	void dequeue(uchar *_buffer,uint32_t _size) ;
        void clear();
	~k9fifo() { delete[] array;};
};

#endif