Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::buffered_ostream Class Reference

#include <buffered_iostream.hpp>

Inheritance diagram for fc::buffered_ostream:
Collaboration diagram for fc::buffered_ostream:

Public Member Functions

 buffered_ostream (ostream_ptr o, size_t bufsize=4096)
 
 buffered_ostream (buffered_ostream &&m)
 
 ~buffered_ostream ()
 
buffered_ostreamoperator= (buffered_ostream &&m)
 
virtual size_t writesome (const char *buf, size_t len)
 
virtual size_t writesome (const std::shared_ptr< const char > &buf, size_t len, size_t offset)
 
virtual void close ()
 
virtual void flush ()
 

Detailed Description

Definition at line 52 of file buffered_iostream.hpp.

Constructor & Destructor Documentation

◆ buffered_ostream() [1/2]

fc::buffered_ostream::buffered_ostream ( ostream_ptr o,
size_t bufsize = 4096 )

Definition at line 153 of file buffered_iostream.cpp.

154 :my( new detail::buffered_ostream_impl( fc::move(os) ) )
155 {
156 }
os_t os

◆ buffered_ostream() [2/2]

fc::buffered_ostream::buffered_ostream ( buffered_ostream && m)

Definition at line 158 of file buffered_iostream.cpp.

159 :my( fc::move(o.my) ){}

◆ ~buffered_ostream()

fc::buffered_ostream::~buffered_ostream ( )

Definition at line 167 of file buffered_iostream.cpp.

167{}

Member Function Documentation

◆ close()

void fc::buffered_ostream::close ( )
virtual

Definition at line 202 of file buffered_iostream.cpp.

203 {
204 flush();
205 my->_ostr->close();
206 }
Here is the call graph for this function:

◆ flush()

void fc::buffered_ostream::flush ( )
virtual

Definition at line 181 of file buffered_iostream.cpp.

182 {
183#ifndef NDEBUG
184 // This code was written with the assumption that you'd only be making one call to flush
185 // at a time so it reuses _shared_write_buffer. If you really need to make concurrent calls to
186 // flush(), you'll need to prevent reusing _shared_write_buffer here
187 struct check_buffer_in_use {
188 bool& _buffer_in_use;
189 check_buffer_in_use(bool& buffer_in_use) : _buffer_in_use(buffer_in_use) { assert(!_buffer_in_use); _buffer_in_use = true; }
190 ~check_buffer_in_use() { assert(_buffer_in_use); _buffer_in_use = false; }
191 } buffer_in_use_checker(my->_shared_write_buffer_in_use);
192#endif
193 const size_t write_buffer_size = 2048;
194 if (!my->_shared_write_buffer)
195 my->_shared_write_buffer.reset(new char[write_buffer_size], [](char* p){ delete[] p; });
196
197 while( size_t bytes_from_rdbuf = static_cast<size_t>(my->_rdbuf.sgetn(my->_shared_write_buffer.get(), write_buffer_size)) )
198 my->_ostr->write( my->_shared_write_buffer, bytes_from_rdbuf );
199 my->_ostr->flush();
200 }
const mie::Vuint & p
Definition bn.cpp:27
Here is the caller graph for this function:

◆ operator=()

buffered_ostream & fc::buffered_ostream::operator= ( buffered_ostream && m)

Definition at line 161 of file buffered_iostream.cpp.

162 {
163 my = fc::move(i.my);
164 return *this;
165 }

◆ writesome() [1/2]

size_t fc::buffered_ostream::writesome ( const char * buf,
size_t len )
virtual

This method will return immediately unless the buffer is full, in which case it will flush which may block.

Definition at line 169 of file buffered_iostream.cpp.

170 {
171 size_t written = static_cast<size_t>(my->_rdbuf.sputn( buf, len ));
172 if( written < len ) { flush(); }
173 return written + static_cast<size_t>(my->_rdbuf.sputn( buf+written, len-written ));
174 }
size_t len
uint8_t buf[2048]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writesome() [2/2]

size_t fc::buffered_ostream::writesome ( const std::shared_ptr< const char > & buf,
size_t len,
size_t offset )
virtual

Definition at line 176 of file buffered_iostream.cpp.

177 {
178 return writesome(buf.get() + offset, len);
179 }
virtual size_t writesome(const char *buf, size_t len)
Here is the call graph for this function:

The documentation for this class was generated from the following files: