<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>GNU CommonC++: ost::ThreadFile Class Reference</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.4.6 --> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li id="current"><a href="classes.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul></div> <div class="tabs"> <ul> <li><a href="classes.html"><span>Alphabetical List</span></a></li> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul></div> <div class="nav"> <a class="el" href="namespaceost.html">ost</a>::<a class="el" href="classost_1_1_thread_file.html">ThreadFile</a></div> <h1>ost::ThreadFile Class Reference</h1><!-- doxytag: class="ost::ThreadFile" --><!-- doxytag: inherits="ost::RandomFile" -->This class defines a database I/O file service that can be shared by multiple threads.This class defines a database I/O file service that can be shared by multiple threads. <a href="#_details">More...</a> <p> <code>#include <<a class="el" href="file_8h-source.html">file.h</a>></code> <p> <p>Inheritance diagram for ost::ThreadFile: <p><center><img src="classost_1_1_thread_file.png" usemap="#ost::ThreadFile_map" border="0" alt=""></center> <map name="ost::ThreadFile_map"> <area href="classost_1_1_random_file.html" alt="ost::RandomFile" shape="rect" coords="55,56,155,80"> <area href="classost_1_1_mutex.html" alt="ost::Mutex" shape="rect" coords="0,0,100,24"> <area href="classost_1_1_file.html" alt="ost::File" shape="rect" coords="110,0,210,24"> </map> <a href="classost_1_1_thread_file-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0"> <tr><td></td></tr> <tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#17e345a69a04ba5b9db9c556925900c1">ThreadFile</a> (const char *path)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Open or create a new database file. <a href="#17e345a69a04ba5b9db9c556925900c1"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#ebf1b7d1658ad10654425eadd1a34052">~ThreadFile</a> ()</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Close and finish a database file. <a href="#ebf1b7d1658ad10654425eadd1a34052"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#634eeae5f8e783d26e484046344a0556">restart</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Restart an existing database; close and re-open. <a href="#634eeae5f8e783d26e484046344a0556"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#3f4dae2704c3780ebccf6abd1f3bc021">fetch</a> (char *address=NULL, <a class="el" href="namespaceost.html#cedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> length=0, off_t position=-1)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Fetch a portion of the file into physical memory. <a href="#3f4dae2704c3780ebccf6abd1f3bc021"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#aa50dd7107aa5384b8536316803bcd11">update</a> (char *address=NULL, <a class="el" href="namespaceost.html#cedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> length=0, off_t position=-1)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Update a portion of a file from physical memory. <a href="#aa50dd7107aa5384b8536316803bcd11"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#0dd1a865c7936e01f3082b216925f418">append</a> (char *address=NULL, <a class="el" href="namespaceost.html#cedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> length=0)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Add new data to the end of the file. <a href="#0dd1a865c7936e01f3082b216925f418"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">off_t </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#09adee0b9978cdc82435c901c850d4e5">getPosition</a> (void)</td></tr> <tr><td class="mdescLeft"> </td><td class="mdescRight">Fetch the current file position marker for this thread. <a href="#09adee0b9978cdc82435c901c850d4e5"></a><br></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#5587d9a579902aa4589ec1777fecd2f6">operator++</a> (void)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="classost_1_1_thread_file.html#48627c57443c979420e3b218f387cff0">operator--</a> (void)</td></tr> </table> <hr><a name="_details"></a><h2>Detailed Description</h2> This class defines a database I/O file service that can be shared by multiple threads.This class defines a database I/O file service that can be shared by multiple threads. <p> 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.<p> <a class="el" href="classost_1_1_thread_file.html">ThreadFile</a> 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 <a class="el" href="classost_1_1_mutex.html">Mutex</a> lock is used to protect concurrent lseek and read/write operations. <a class="el" href="classost_1_1_thread_file.html">ThreadFile</a> managed databases are assumed to be used only by the local server and through a single file descriptor.<p> <dl compact><dt><b>Author:</b></dt><dd>David Sugar <<a href="mailto:dyfet@ostel.com">dyfet@ostel.com</a>> </dd></dl> <p> <hr><h2>Constructor & Destructor Documentation</h2> <a class="anchor" name="17e345a69a04ba5b9db9c556925900c1"></a><!-- doxytag: member="ost::ThreadFile::ThreadFile" ref="17e345a69a04ba5b9db9c556925900c1" args="(const char *path)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">ost::ThreadFile::ThreadFile </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const char * </td> <td class="mdname1" valign="top" nowrap> <em>path</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> Open or create a new database file. <p> You should also use Initial.<p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>path</em> </td><td>pathname of database to open. </td></tr> </table> </dl> </td> </tr> </table> <a class="anchor" name="ebf1b7d1658ad10654425eadd1a34052"></a><!-- doxytag: member="ost::ThreadFile::~ThreadFile" ref="ebf1b7d1658ad10654425eadd1a34052" args="()" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">virtual ost::ThreadFile::~ThreadFile </td> <td class="md" valign="top">( </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> Close and finish a database file. <p> </td> </tr> </table> <hr><h2>Member Function Documentation</h2> <a class="anchor" name="0dd1a865c7936e01f3082b216925f418"></a><!-- doxytag: member="ost::ThreadFile::append" ref="0dd1a865c7936e01f3082b216925f418" args="(char *address=NULL, ccxx_size_t length=0)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> ost::ThreadFile::append </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">char * </td> <td class="mdname" nowrap> <em>address</em> = <code>NULL</code>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="namespaceost.html#cedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> </td> <td class="mdname" nowrap> <em>length</em> = <code>0</code></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> Add new data to the end of the file. <p> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>address</em> </td><td>address to use, or NULL if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>length</em> </td><td>length to use, or 0 if same as last I/O. </td></tr> </table> </dl> </td> </tr> </table> <a class="anchor" name="3f4dae2704c3780ebccf6abd1f3bc021"></a><!-- doxytag: member="ost::ThreadFile::fetch" ref="3f4dae2704c3780ebccf6abd1f3bc021" args="(char *address=NULL, ccxx_size_t length=0, off_t position=-1)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> ost::ThreadFile::fetch </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">char * </td> <td class="mdname" nowrap> <em>address</em> = <code>NULL</code>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="namespaceost.html#cedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> </td> <td class="mdname" nowrap> <em>length</em> = <code>0</code>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>off_t </td> <td class="mdname" nowrap> <em>position</em> = <code>-1</code></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> Fetch a portion of the file into physical memory. <p> This can use state information to fetch the current record multiple times.<p> <dl compact><dt><b>Returns:</b></dt><dd>errSuccess on success. </dd></dl> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>address</em> </td><td>address to use, or NULL if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>length</em> </td><td>length to use, or 0 if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>position</em> </td><td>file position to use -1 if same as last I/O. </td></tr> </table> </dl> </td> </tr> </table> <a class="anchor" name="09adee0b9978cdc82435c901c850d4e5"></a><!-- doxytag: member="ost::ThreadFile::getPosition" ref="09adee0b9978cdc82435c901c850d4e5" args="(void)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">off_t ost::ThreadFile::getPosition </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> Fetch the current file position marker for this thread. <p> <dl compact><dt><b>Returns:</b></dt><dd>file position offset. </dd></dl> </td> </tr> </table> <a class="anchor" name="5587d9a579902aa4589ec1777fecd2f6"></a><!-- doxytag: member="ost::ThreadFile::operator++" ref="5587d9a579902aa4589ec1777fecd2f6" args="(void)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">bool ost::ThreadFile::operator++ </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> </td> </tr> </table> <a class="anchor" name="48627c57443c979420e3b218f387cff0"></a><!-- doxytag: member="ost::ThreadFile::operator--" ref="48627c57443c979420e3b218f387cff0" args="(void)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">bool ost::ThreadFile::operator-- </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> </td> </tr> </table> <a class="anchor" name="634eeae5f8e783d26e484046344a0556"></a><!-- doxytag: member="ost::ThreadFile::restart" ref="634eeae5f8e783d26e484046344a0556" args="(void)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> ost::ThreadFile::restart </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [virtual]</code></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> Restart an existing database; close and re-open. <p> <dl compact><dt><b>Returns:</b></dt><dd>errSuccess if successful. </dd></dl> <p> Reimplemented from <a class="el" href="classost_1_1_random_file.html#e78c71b1e3fab5861bc9fdae595829a7">ost::RandomFile</a>. </td> </tr> </table> <a class="anchor" name="aa50dd7107aa5384b8536316803bcd11"></a><!-- doxytag: member="ost::ThreadFile::update" ref="aa50dd7107aa5384b8536316803bcd11" args="(char *address=NULL, ccxx_size_t length=0, off_t position=-1)" --><p> <table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"><a class="el" href="classost_1_1_file.html#c65e9af20a431154c8d8a811d4c58bde">Error</a> ost::ThreadFile::update </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">char * </td> <td class="mdname" nowrap> <em>address</em> = <code>NULL</code>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="namespaceost.html#cedd0902cc2709bd066b9f8a2d1f44a0">ccxx_size_t</a> </td> <td class="mdname" nowrap> <em>length</em> = <code>0</code>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap>off_t </td> <td class="mdname" nowrap> <em>position</em> = <code>-1</code></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr> </table> <table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td> <p> Update a portion of a file from physical memory. <p> This can use state information to commit the last read record.<p> <dl compact><dt><b>Returns:</b></dt><dd>errSuccess on success. </dd></dl> <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>address</em> </td><td>address to use, or NULL if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>length</em> </td><td>length to use, or 0 if same as last I/O. </td></tr> <tr><td valign="top"></td><td valign="top"><em>position</em> </td><td>file position to use or -1 if same as last I/O. </td></tr> </table> </dl> </td> </tr> </table> <hr>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="file_8h-source.html">file.h</a></ul> <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 19 10:50:56 2006 for GNU CommonC++ by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address> </body> </html>