| java.lang.Object seda.sandStorm.core.SimpleSink seda.sandStorm.lib.aDisk.AFile
AFile | public class AFile extends SimpleSink (Code) | | This class represents an asynchronous file I/O interface.
To use this class, the user creates an AFile corresponding to a given
filename. AFile implements SinkIF, and as such you can enqueue
I/O requests to be performed on this file; all such requests must be
subclasses of AFileRequest. The read, write, and
seek methods are also provided for convenience.
author: Matt Welsh See Also: SinkIF, AFileRequest |
Constructor Summary | |
public | AFile(String name, SinkIF compQ, boolean create, boolean readOnly) Open the file with the given pathname. |
Method Summary | |
public synchronized void | close() Close the file after all enqueued requests have completed. | public synchronized void | enqueue(QueueElementIF req) Enqueues the given request (which must be an AFileRequest)
to the file. | public synchronized boolean | enqueue_lossy(QueueElementIF req) Enqueues the given request (which must be an AFileRequest)
to the file. | public synchronized void | enqueue_many(QueueElementIF[] elements) Enqueues the given requests (which must be AFileRequests)
to the file. | public synchronized void | flush() Causes a SinkFlushedEvent to be posted on the file's completion queue
when all pending requests have completed. | public String | getFilename() | AFileImpl | getImpl() Returns the implementation-specific object representing this AFile. | public synchronized void | read(BufferElement buf) Enqueues a read request at the current file offset. | public synchronized void | read(BufferElement buf, int offset) Enqueues a read request at the given file offset. | public synchronized void | seek(int offset) Position the file to the given offset. | public AFileStat | stat() Return information on the properties of the file. | public String | toString() | public synchronized void | write(BufferElement buf) Enqueues a write request at the current file offset. | public synchronized void | write(BufferElement buf, int offset) Enqueues a write request at the given file offset. |
AFile | public AFile(String name, SinkIF compQ, boolean create, boolean readOnly) throws IOException(Code) | | Open the file with the given pathname.
Parameters: name - A system-dependent filename. Parameters: compQ - The default completion queue on which read and writecompletion events will be posted. A completion queue canbe specified for each individual request by setting the 'compQ'field in the associated AFileRequest. Parameters: create - If true, creates the file if it does not exist. Parameters: create - If true, opens the file in read-only mode. exception: FileNotFoundException - If the file does not exist and 'create' is false. |
close | public synchronized void close()(Code) | | Close the file after all enqueued requests have completed.
Disallows any additional requests to be enqueued on this file.
A SinkClosedEvent will be posted on the file's completion queue
when the close is complete.
|
enqueue_lossy | public synchronized boolean enqueue_lossy(QueueElementIF req)(Code) | | Enqueues the given request (which must be an AFileRequest)
to the file.
|
enqueue_many | public synchronized void enqueue_many(QueueElementIF[] elements) throws SinkException(Code) | | Enqueues the given requests (which must be AFileRequests)
to the file.
|
flush | public synchronized void flush()(Code) | | Causes a SinkFlushedEvent to be posted on the file's completion queue
when all pending requests have completed.
|
getImpl | AFileImpl getImpl()(Code) | | Returns the implementation-specific object representing this AFile.
Package access only.
|
read | public synchronized void read(BufferElement buf, int offset) throws SinkException(Code) | | Enqueues a read request at the given file offset. This is equivalent
to a call to seek() before read().
|
seek | public synchronized void seek(int offset) throws SinkException(Code) | | Position the file to the given offset. As with read and writes,
seek requests are performed asynchronously; only read and write
requests enqueued after the seek operation will use the new file
offset.
|
stat | public AFileStat stat()(Code) | | Return information on the properties of the file.
|
write | public synchronized void write(BufferElement buf, int offset) throws SinkException(Code) | | Enqueues a write request at the given file offset. This is
equivalent to a call to seek() before write().
|
|
|