mrfioc2  2.3.0
bufrxmgr.h
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2010 Brookhaven Science Associates, as Operator of
3 * Brookhaven National Laboratory.
4 * Copyright (c) 2015 Paul Scherrer Institute (PSI), Villigen, Switzerland
5 * mrfioc2 is distributed subject to a Software License Agreement found
6 * in file LICENSE that is included with this distribution.
7 \*************************************************************************/
8 /*
9  * Author: Michael Davidsaver <mdavidsaver@gmail.com>
10  */
11 
12 #ifndef BUFRXMGR_H_INC
13 #define BUFRXMGR_H_INC
14 
15 
16 #include <ellLib.h>
17 #include <callback.h>
18 
19 #include "mrf/databuf.h"
20 
21 class epicsShareClass bufRxManager : public dataBufRx
22 {
23 public:
24  bufRxManager(const std::string&, unsigned int qdepth, unsigned int bsize=0);
25 
26  virtual ~bufRxManager();
27 
28  unsigned int bsize(){return m_bsize;};
29 
30  epicsUInt8* getFree(unsigned int*);
31 
32  void receive(epicsUInt8*,unsigned int);
33 
42  virtual void dataRxError(dataBufComplete, void*) OVERRIDE FINAL;
43 
50  virtual void dataRxAddReceive(dataBufComplete fptr, void* arg=0) OVERRIDE FINAL;
51 
54  virtual void dataRxDeleteReceive(dataBufComplete fptr, void* arg=0) OVERRIDE FINAL;
55 
56 private:
57  epicsMutex guard;
58 
59  struct listener {
60  ELLNODE node;
61 
62  dataBufComplete fn;
63  void *fnarg;
64  };
65  ELLLIST dispatch;
66 
67  dataBufComplete onerror;
68  void* onerror_arg;
69 
70 protected:
71  void haderror(epicsStatus e){onerror(onerror_arg,e,0,NULL);}
72 
73 private:
74  ELLLIST freebufs;
75  ELLLIST usedbufs;
76 
77  CALLBACK received_cb;
78  static void received(CALLBACK*);
79 
80  struct buffer {
81  ELLNODE node;
82  unsigned int used;
83  epicsUInt8 data[1];
84  };
85 
86  const unsigned int m_bsize;
87 };
88 
89 #endif // BUFRXMGR_H_INC
virtual void dataRxDeleteReceive(dataBufComplete fptr, void *arg=0)=0
Unregister.
void haderror(epicsStatus e)
Definition: bufrxmgr.h:71
unsigned int bsize()
Definition: bufrxmgr.h:28
virtual void dataRxAddReceive(dataBufComplete fptr, void *arg=0)=0
Register to receive data buffers.
void(* dataBufComplete)(void *arg, epicsStatus ok, epicsUInt32 len, const epicsUInt8 *buf)
Definition: databuf.h:31
virtual void dataRxError(dataBufComplete, void *)=0
Notification if Rx queue overflows.