libcsdbg  1.28
C++ exception (and generic) stack trace debug library
streambuf & csdbg::streambuf::flush ( )
pure virtual

To be implemented.

Flush the buffered data to the stream.

Returns
*this
Exceptions
i32(errno)
Note
The buffer remains as is, if the stream isn't open
Synchronous output is enforced (even if O_NONBLOCK is specified)

Implemented in csdbg::sttybuf, csdbg::tcpsockbuf, and csdbg::filebuf.

Definition at line 156 of file streambuf.cpp.

References csdbg::string::clear(), likely, csdbg::string::m_data, m_handle, csdbg::string::m_length, and unlikely.

Referenced by csdbg::filebuf::flush(), csdbg::tcpsockbuf::flush(), and csdbg::sttybuf::flush().

157 {
158  i32 offset = 0, sz = m_length;
159  while ( likely(sz > 0) ) {
160  i32 written = write(m_handle, m_data + offset, sz);
161  if ( unlikely(written < 0) )
162  switch (errno) {
163  case EINTR:
164  case EAGAIN:
165  continue;
166 
167  default:
168  throw errno;
169  }
170 
171  sz -= written;
172  offset += written;
173  }
174 
175  /* Clear the buffer */
176  clear();
177  return *this;
178 }
i32 m_handle
Stream handle (descriptor)
Definition: streambuf.hpp:43
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
virtual string & clear()
Clear contents.
Definition: string.cpp:387
i8 * m_data
String data.
Definition: string.hpp:42
int i32
32-bit signed integer
Definition: config.hpp:82
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349
u32 m_length
Character count.
Definition: string.hpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function: