aboutsummaryrefslogtreecommitdiff
path: root/include/Fifo.h
blob: c060079ca8cb956ca3c86390090e435f45dbf0a5 (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
#ifndef _FIFO_H_
#define _FIFO_H_

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif


#include <memory.h>
#include <pthread.h>

class Fifo
{
 public:
  Fifo();
  Fifo(unsigned int size);
  ~Fifo();
  void Flush();
  int IsAlloc(void) { return astate; }
  int ReAlloc(unsigned int size);
  void * Read(void *buf, unsigned int &len);
  int Write(void *buf, unsigned int len);
  unsigned int FreeSpace(void);
  unsigned int UsedSpace(void);
 private:
  char *buffer;
  unsigned int astate;
  unsigned int totsize, start, datasize;
  pthread_mutex_t mut;
};
#endif