class ThreadFile

This class defines a database I/O file service that can be shared by multiple threads. More...

Full nameost::ThreadFile
Definition#include <file.h>
Inheritsost::RandomFile [public ], ost::RandomFile [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

This class defines a database I/O file service that can be shared by multiple threads. All threads access a global copy of the database object, and mutex locks can be used to preserve transaction integrety. pread/pwrite calls can be used for optimized I/O when supported.

ThreadFile is meant for use by a threaded database server where multiple threads may each perform semi-independent operations on a given database table stored on disk. A special "fcb" structure is used to hold file "state", and pread/pwrite is used whenever possible for optimized I/O. On systems that do not offer pwread/pwrite, a Mutex lock is used to protect concurrent lseek and read/write operations. ThreadFile managed databases are assumed to be used only by the local server and through a single file descriptor.

 ThreadFile (const char *path)

ThreadFile

Open or create a new database file. You should also use Initial.

Parameters:
pathnameof database to open.

 ~ThreadFile ()

~ThreadFile

[virtual]

Close and finish a database file.

fileerror_t  Restart (void)

Restart

Restart an existing database; close and re-open.

Returns: FILE_SUCCESS if successful.

Reimplemented from RandomFile.

fileerror_t  Fetch (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Fetch

Fetch a portion of the file into physical memory. This can use state information to fetch the current record multiple times.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Update (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Update

Update a portion of a file from physical memory. This can use state information to commit the last read record.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use or -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Append (char * address = NULL, ccxx_size_t length = 0)

Append

Add new data to the end of the file.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.

off_t  getPosition (void)

getPosition

Fetch the current file position marker for this thread.

Returns: file position offset.

bool  operator++ (void)

operator++

bool  operator-- (void)

operator--

 ThreadFile (const char *path)

ThreadFile

Open or create a new database file. You should also use Initial.

Parameters:
pathnameof database to open.

 ~ThreadFile ()

~ThreadFile

[virtual]

Close and finish a database file.

fileerror_t  Restart (void)

Restart

Restart an existing database; close and re-open.

Returns: FILE_SUCCESS if successful.

Reimplemented from RandomFile.

fileerror_t  Fetch (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Fetch

Fetch a portion of the file into physical memory. This can use state information to fetch the current record multiple times.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Update (char * address = NULL, ccxx_size_t length = 0, off_t position = -1)

Update

Update a portion of a file from physical memory. This can use state information to commit the last read record.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.
fileposition to use or -1 if same as last I/O.

Returns: FILE_SUCCESS on success.

fileerror_t  Append (char * address = NULL, ccxx_size_t length = 0)

Append

Add new data to the end of the file.

Parameters:
addressto use, or NULL if same as last I/O.
lengthto use, or 0 if same as last I/O.

off_t  getPosition (void)

getPosition

Fetch the current file position marker for this thread.

Returns: file position offset.

bool  operator++ (void)

operator++

bool  operator-- (void)

operator--