MySQL 9.1.0
Source Code Documentation
SyncFileIO Class Reference

Helper class for doing synchronous file IO. More...

#include <os0file.h>

Public Member Functions

 SyncFileIO (os_file_t fh, void *buf, ulint n, os_offset_t offset)
 Constructor. More...
 
 ~SyncFileIO ()=default
 Destructor. More...
 
ssize_t execute (const IORequest &request)
 Do the read/write. More...
 
dberr_t execute_with_retry (const IORequest &request, const size_t max_retries=NUM_RETRIES_ON_PARTIAL_IO)
 Do the read/write with retry. More...
 
void advance (ssize_t n_bytes)
 Move the read/write offset up to where the partial IO succeeded. More...
 

Private Attributes

os_file_t m_fh
 Open file handle. More...
 
void * m_buf
 Buffer to read/write. More...
 
ssize_t m_n
 Number of bytes to read/write. More...
 
os_offset_t m_offset
 Offset from where to read/write. More...
 
const size_t m_orig_bytes
 The total number of bytes to be read/written. More...
 

Detailed Description

Helper class for doing synchronous file IO.

Currently, the objective is to hide the OS specific code, so that the higher level functions aren't peppered with "#ifdef". Makes the code flow difficult to follow.

Constructor & Destructor Documentation

◆ SyncFileIO()

SyncFileIO::SyncFileIO ( os_file_t  fh,
void *  buf,
ulint  n,
os_offset_t  offset 
)
inline

Constructor.

Parameters
[in]fhFile handle
[in,out]bufBuffer to read/write
[in]nNumber of bytes to read/write
[in]offsetOffset where to read or write

◆ ~SyncFileIO()

SyncFileIO::~SyncFileIO ( )
default

Destructor.

Member Function Documentation

◆ advance()

void SyncFileIO::advance ( ssize_t  n_bytes)
inline

Move the read/write offset up to where the partial IO succeeded.

Parameters
[in]n_bytesThe number of bytes to advance

◆ execute()

ssize_t SyncFileIO::execute ( const IORequest request)

Do the read/write.

Parameters
[in]requestThe IO context and type
Returns
the number of bytes read/written or negative value on error

◆ execute_with_retry()

dberr_t SyncFileIO::execute_with_retry ( const IORequest request,
const size_t  max_retries = NUM_RETRIES_ON_PARTIAL_IO 
)

Do the read/write with retry.

Parameters
[in]requestThe IO context and type
[in]max_retriesthe maximum number of retries on partial i/o.
Returns
DB_SUCCESS on success, an error code on failure.

Member Data Documentation

◆ m_buf

void* SyncFileIO::m_buf
private

Buffer to read/write.

◆ m_fh

os_file_t SyncFileIO::m_fh
private

Open file handle.

◆ m_n

ssize_t SyncFileIO::m_n
private

Number of bytes to read/write.

◆ m_offset

os_offset_t SyncFileIO::m_offset
private

Offset from where to read/write.

◆ m_orig_bytes

const size_t SyncFileIO::m_orig_bytes
private

The total number of bytes to be read/written.


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