RTXI  2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fifo.h
Go to the documentation of this file.
1 /*
2  The Real-Time eXperiment Interface (RTXI)
3  Copyright (C) 2011 Georgia Institute of Technology, University of Utah, Weill Cornell Medical College
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef FIFO_H
21 #define FIFO_H
22 
23 #include <cstdlib>
24 #include <pthread.h>
25 
26 class Fifo
27 {
28 
29 public:
30 
31  Fifo(size_t);
32  ~Fifo(void);
33 
34  size_t read(void *,size_t,bool =true);
35  size_t write(const void *,size_t);
36 
37 private:
38 
39  char *data;
40  volatile int rptr;
41  volatile int wptr;
42  size_t size;
43  pthread_mutex_t mutex;
44  pthread_cond_t data_available;
45 
46 };
47 
48 #endif /* FIFO_H */
~Fifo(void)
Definition: fifo.cpp:34
Fifo(size_t)
Definition: fifo.cpp:26
pthread_cond_t data_available
Definition: fifo.h:44
volatile int wptr
Definition: fifo.h:41
char * data
Definition: fifo.h:39
size_t read(void *, size_t, bool=true)
Definition: fifo.cpp:42
Definition: fifo.h:26
pthread_mutex_t mutex
Definition: fifo.h:43
volatile int rptr
Definition: fifo.h:40
size_t size
Definition: fifo.h:42
size_t write(const void *, size_t)
Definition: fifo.cpp:81