[APE Index] [APE Hierarchy] [Headers]
Shared concurrent file access from multiple threads. More...
#include <file.h>
Locked files provide clean access to a database file that is shared between multiple processes via file locking. A seperate and more efficient methodology is provided here to enable multiple threads to access the same file descriptor concurrently. While shared files do not include thread exclusive file region locking, such locking can be established with in memory based tables rather than kernel file locks for speed if needed.
[public]
Create a new disk file that will be shared between multiple threads. A file name, access mode, and file permissions to use when creating a new file are specified. On failure an exception is thrown.
access | file access mode. |
perm | file permission to assign when creating a new file. |
fname | path name of disk file to open or create. |
[public]
Open an existing disk file for shared access between multiple threads. A file name and file access mode must be specified. If the file does not exist or cannot be opened, an exception is thrown.
access | file access mode. |
fname | path name of disk file to open. |
[public]
Open a copy of an existing "File" through a duplicate object for shared access from multiple threads. This essentially uses the Posix dup() call to duplicate the file descriptor involved.
f | an existing File class to duplicate from. |
[public]
Create a shared file "class" to reference an existing and already open file descriptor from multiple threads. This is kind of like "fdopen" in purpose, and simply allows any existing file descriptor to be manipulated by the thread shared methods.
fd | an existing and already open file descriptor. |
[public]
Close the existing shared file object and release any used resources.
[public]
Write data to the end of a specified share file exclusivily. The mutex lock is used to assure the write operation is not interfered with by other threads until it completes.
buf | pointer to data to write to the file. |
len | number of bytes to write. |
[public]
Read data from a specified file offset exclusivily. The Mutex lock is used to assure the read operation can complete without interference by other threads. While the current file offset must be specified and tracked seperately by each thread on it's own, an enhanced version may soon use a ThreadKey for this purpose.
pos | file offset to start read from file. |
buf | pointer to store data read from file. |
len | number of bytes to read. |
[public]
Write data to a specified file offset exclusivily. The Mutex lock is used to assure the write operation can complete without interference by other threads. While the current file offset must be specified and tracked seperately by each thread on it's own, an enhanced version may soon use a ThreadKey for this purpose.
pos | file offset to start file write. |
buf | pointer to data to write to the file. |
len | number of bytes to write. |
| Kdoc |