This is Unofficial EPICS BASE Doxygen Site
comBuf.cpp
Go to the documentation of this file.
1 /*************************************************************************\
2 * Copyright (c) 2002 The University of Chicago, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * EPICS BASE is distributed subject to a Software License Agreement found
7 * in file LICENSE that is included with this distribution.
8 \*************************************************************************/
9 /*
10  *
11  *
12  * L O S A L A M O S
13  * Los Alamos National Laboratory
14  * Los Alamos, New Mexico 87545
15  *
16  * Copyright, 1986, The Regents of the University of California.
17  *
18  *
19  * Author Jeffrey O. Hill
20  * johill@lanl.gov
21  */
22 
23 #include <stdexcept>
24 
25 #define epicsAssertAuthor "Jeff Hill johill@lanl.gov"
26 
27 #include "comBuf.h"
28 #include "errlog.h"
29 
30 bool comBuf::flushToWire ( wireSendAdapter & wire, const epicsTime & currentTime )
31 {
32  unsigned index = this->nextReadIndex;
33  unsigned finalIndex = this->commitIndex;
34  while ( index < finalIndex ) {
35  unsigned nBytes = wire.sendBytes (
36  &this->buf[index], finalIndex - index, currentTime );
37  if ( nBytes == 0u ) {
38  this->nextReadIndex = index;
39  return false;
40  }
41  index += nBytes;
42  }
43  this->nextReadIndex = index;
44  return true;
45 }
46 
47 // throwing the exception from a function that isnt inline
48 // shrinks the GNU compiled object code
50 {
52 }
53 
54 void comBuf::operator delete ( void * )
55 {
56  // Visual C++ .net appears to require operator delete if
57  // placement operator delete is defined? I smell a ms rat
58  // because if I declare placement new and delete, but
59  // comment out the placement delete definition there are
60  // no undefined symbols.
61  errlogPrintf ( "%s:%d this compiler is confused about placement delete - memory was probably leaked",
62  __FILE__, __LINE__ );
63 }
64 
bool flushToWire(wireSendAdapter &, const epicsTime &currentTime)
Definition: comBuf.cpp:30
epicsUInt8 buf[comBufSize]
Definition: comBuf.h:115
static void throwInsufficentBytesException()
Definition: comBuf.cpp:49
int errlogPrintf(const char *pFormat,...)
Definition: errlog.c:105
virtual ~comBufMemoryManager()
Definition: comBuf.cpp:65
virtual unsigned sendBytes(const void *pBuf, unsigned nBytesInBuf, const class epicsTime &currentTime)=0
unsigned nextReadIndex
Definition: comBuf.h:114