SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Public Attributes | List of all members
leansdr::pipebuf< T > Struct Template Reference

#include <framework.h>

+ Inheritance diagram for leansdr::pipebuf< T >:
+ Collaboration diagram for leansdr::pipebuf< T >:

Public Member Functions

int sizeofT ()
 
 pipebuf (scheduler *sch, const char *name, unsigned long size)
 
int add_reader ()
 
void pack ()
 
long long hash ()
 
void dump (std::size_t *total_bufs)
 
- Public Member Functions inherited from leansdr::pipebuf_common
 pipebuf_common (const char *_name)
 
virtual ~pipebuf_common ()
 

Public Attributes

T * buf
 
T * rds [MAX_READERS]
 
int nrd
 
T * wr
 
T * end
 
unsigned long min_write
 
unsigned long total_written
 
unsigned long total_read
 
- Public Attributes inherited from leansdr::pipebuf_common
const char * name
 

Detailed Description

template<typename T>
struct leansdr::pipebuf< T >

Definition at line 203 of file framework.h.

Constructor & Destructor Documentation

◆ pipebuf()

template<typename T>
leansdr::pipebuf< T >::pipebuf ( scheduler sch,
const char *  name,
unsigned long  size 
)
inline

Definition at line 216 of file framework.h.

216  : pipebuf_common(name),
217  buf(new T[size]),
218  nrd(0), wr(buf),
219  end(buf + size),
220  min_write(1),
221  total_written(0),
222  total_read(0)
223  {
224  sch->add_pipe(this);
225  }
unsigned long total_read
Definition: framework.h:276
const char * name
Definition: framework.h:70
unsigned long min_write
Definition: framework.h:275
pipebuf_common(const char *_name)
Definition: framework.h:72
unsigned long total_written
Definition: framework.h:276

Member Function Documentation

◆ add_reader()

template<typename T>
int leansdr::pipebuf< T >::add_reader ( )
inline

Definition at line 227 of file framework.h.

228  {
229  if (nrd == MAX_READERS)
230  fail("too many readers");
231  rds[nrd] = wr;
232  return nrd++;
233  }
T * rds[MAX_READERS]
Definition: framework.h:206
void fail(const char *s)
Definition: framework.cpp:11

◆ dump()

template<typename T>
void leansdr::pipebuf< T >::dump ( std::size_t *  total_bufs)
inlinevirtual

Reimplemented from leansdr::pipebuf_common.

Definition at line 252 of file framework.h.

253  {
254  if (total_written < 10000)
255  fprintf(stderr, ".%-16s : %4ld/%4ld", name, total_read,
256  total_written);
257  else if (total_written < 1000000)
258  fprintf(stderr, ".%-16s : %3ldk/%3ldk", name, total_read / 1000,
259  total_written / 1000);
260  else
261  fprintf(stderr, ".%-16s : %3ldM/%3ldM", name, total_read / 1000000,
262  total_written / 1000000);
263  *total_bufs += (end - buf) * sizeof(T);
264  unsigned long nw = end - wr;
265  fprintf(stderr, " %6ld writable %c,", nw, (nw < min_write) ? '!' : ' ');
266  T *rd = wr;
267  for (int j = 0; j < nrd; ++j)
268  if (rds[j] < rd)
269  rd = rds[j];
270  fprintf(stderr, " %6d unread (", (int)(wr - rd));
271  for (int j = 0; j < nrd; ++j)
272  fprintf(stderr, " %d", (int)(wr - rds[j]));
273  fprintf(stderr, " )\n");
274  }
T * rds[MAX_READERS]
Definition: framework.h:206
unsigned long total_read
Definition: framework.h:276
const char * name
Definition: framework.h:70
unsigned long min_write
Definition: framework.h:275
unsigned long total_written
Definition: framework.h:276

◆ hash()

template<typename T>
long long leansdr::pipebuf< T >::hash ( )
inlinevirtual

Reimplemented from leansdr::pipebuf_common.

Definition at line 247 of file framework.h.

248  {
249  return total_written + total_read;
250  }
unsigned long total_read
Definition: framework.h:276
unsigned long total_written
Definition: framework.h:276

◆ pack()

template<typename T>
void leansdr::pipebuf< T >::pack ( )
inline

Definition at line 235 of file framework.h.

Referenced by leansdr::pipewriter< leansdr::complex< leansdr::f32 > >::writable().

236  {
237  T *rd = wr;
238  for (int i = 0; i < nrd; ++i)
239  if (rds[i] < rd)
240  rd = rds[i];
241  memmove(buf, rd, (wr - rd) * sizeof(T));
242  wr -= rd - buf;
243  for (int i = 0; i < nrd; ++i)
244  rds[i] -= rd - buf;
245  }
T * rds[MAX_READERS]
Definition: framework.h:206
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ sizeofT()

template<typename T>
int leansdr::pipebuf< T >::sizeofT ( )
inlinevirtual

Reimplemented from leansdr::pipebuf_common.

Definition at line 211 of file framework.h.

212  {
213  return sizeof(T);
214  }

Member Data Documentation

◆ buf

template<typename T>
T* leansdr::pipebuf< T >::buf

Definition at line 205 of file framework.h.

◆ end

template<typename T>
T* leansdr::pipebuf< T >::end

◆ min_write

template<typename T>
unsigned long leansdr::pipebuf< T >::min_write

◆ nrd

template<typename T>
int leansdr::pipebuf< T >::nrd

Definition at line 207 of file framework.h.

◆ rds

template<typename T>
T* leansdr::pipebuf< T >::rds[MAX_READERS]

◆ total_read

template<typename T>
unsigned long leansdr::pipebuf< T >::total_read

◆ total_written

template<typename T>
unsigned long leansdr::pipebuf< T >::total_written

◆ wr

template<typename T>
T* leansdr::pipebuf< T >::wr

The documentation for this struct was generated from the following file: