|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object seda.sandStorm.core.SimpleSink seda.sandStorm.lib.aDisk.AFile
public class AFile
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.
SinkIF, AFileRequest
Field Summary | |
---|---|
private SinkIF |
compQ
|
private java.lang.String |
fname
|
private AFileImpl |
impl
|
Constructor Summary | |
---|---|
AFile(java.lang.String name,
SinkIF compQ,
boolean create,
boolean readOnly)
Open the file with the given pathname. |
Method Summary | |
---|---|
void |
close()
Close the file after all enqueued requests have completed. |
boolean |
enqueue_lossy(QueueElementIF req)
Enqueues the given request (which must be an AFileRequest) to the file. |
void |
enqueue_many(QueueElementIF[] elements)
Enqueues the given requests (which must be AFileRequests) to the file. |
void |
enqueue(QueueElementIF req)
Enqueues the given request (which must be an AFileRequest) to the file. |
void |
flush()
Causes a SinkFlushedEvent to be posted on the file's completion queue when all pending requests have completed. |
java.lang.String |
getFilename()
|
(package private) AFileImpl |
getImpl()
Returns the implementation-specific object representing this AFile. |
void |
read(BufferElement buf)
Enqueues a read request at the current file offset. |
void |
read(BufferElement buf,
int offset)
Enqueues a read request at the given file offset. |
void |
seek(int offset)
Position the file to the given offset. |
AFileStat |
stat()
Return information on the properties of the file. |
java.lang.String |
toString()
|
void |
write(BufferElement buf)
Enqueues a write request at the current file offset. |
void |
write(BufferElement buf,
int offset)
Enqueues a write request at the given file offset. |
Methods inherited from class seda.sandStorm.core.SimpleSink |
---|
enqueue_abort, enqueue_commit, enqueue_prepare, getEnqueuePredicate, profileSize, setEnqueuePredicate, size |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.lang.String fname
private AFileImpl impl
private SinkIF compQ
Constructor Detail |
---|
public AFile(java.lang.String name, SinkIF compQ, boolean create, boolean readOnly) throws java.io.IOException
name
- A system-dependent filename.compQ
- The default completion queue on which read and write
completion events will be posted. A completion queue can
be specified for each individual request by setting the 'compQ'
field in the associated AFileRequest.create
- If true, creates the file if it does not exist.create
- If true, opens the file in read-only mode.
java.io.FileNotFoundException
- If the file does not exist and
'create' is false.
java.io.IOException
Method Detail |
---|
public void enqueue(QueueElementIF req) throws SinkException
enqueue
in interface SinkIF
enqueue
in class SimpleSink
req
- The QueueElementIF
to enqueue
SinkFullException
- Indicates that the sink is temporarily full.
SinkClosedException
- Indicates that the sink is
no longer being serviced.
SinkException
public boolean enqueue_lossy(QueueElementIF req)
enqueue_lossy
in interface SinkIF
enqueue_lossy
in class SimpleSink
req
- The QueueElementIF
to enqueue
public void enqueue_many(QueueElementIF[] elements) throws SinkException
enqueue_many
in interface SinkIF
enqueue_many
in class SimpleSink
elements
- The element array to enqueue
SinkFullException
- Indicates that the sink is temporarily full.
SinkClosedException
- Indicates that the sink is
no longer being serviced.
SinkException
public void write(BufferElement buf) throws SinkException
SinkException
public void write(BufferElement buf, int offset) throws SinkException
SinkException
public void read(BufferElement buf) throws SinkException
SinkException
public void read(BufferElement buf, int offset) throws SinkException
SinkException
public void seek(int offset) throws SinkException
SinkException
public AFileStat stat()
public java.lang.String getFilename()
public void close()
public void flush()
AFileImpl getImpl()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |