RTXI  2.4
The Real-Time eXperiment Interface Documentation
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 
31 class Fifo
32 {
33 
34 public:
35 
41  Fifo(size_t);
42 
46  ~Fifo(void);
47 
58  size_t read(void *,size_t,bool =true);
59 
67  size_t write(const void *,size_t);
68 
69 private:
70 
71  char *data;
72  volatile int rptr;
73  volatile int wptr;
74  size_t size;
75  pthread_mutex_t mutex;
76  pthread_cond_t data_available;
77 
78 };
79 
80 #endif /* FIFO_H */
Fifo::read
size_t read(void *, size_t, bool=true)
Definition: fifo.cpp:42
Fifo::Fifo
Fifo(size_t)
Definition: fifo.cpp:26
Fifo
Definition: fifo.h:31
Fifo::write
size_t write(const void *, size_t)
Definition: fifo.cpp:81
Fifo::~Fifo
~Fifo(void)
Definition: fifo.cpp:34