|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.lts.ipc.fifo.FIFOImpl
public class FIFOImpl
An internal class that provides the underlying system calls needed to implement named pipes.
This class is implementation dependent and not intended for general use.
Nested Class Summary | |
---|---|
static class |
FIFOImpl.PipeDirection
The role a client is taking (reader/writer) when using a named pipe. |
Field Summary | |
---|---|
static int |
BLOCKING_MODE_BLOCKING
|
static int |
BLOCKING_MODE_NON_BLOCKING
|
static int |
DIRECTION_READER
|
static int |
DIRECTION_WRITER
|
static int |
SELECT_BOTH
|
static int |
SELECT_READING
|
static int |
SELECT_WRITING
|
Constructor Summary | |
---|---|
FIFOImpl(java.lang.String virtualName)
|
Method Summary | |
---|---|
void |
connectNonBlocking(FIFOResult result)
Connect to the underlying FIFO. |
FIFOResult |
create()
|
void |
createNonBlocking(FIFOResult result,
java.lang.String name)
|
protected java.lang.String |
getActualName()
|
protected int |
getBufferSize()
|
protected FIFOImpl.PipeDirection |
getDirection()
|
protected int |
getDirectionInt()
|
protected long |
getHandle()
|
java.lang.String |
getVirtualName()
|
protected void |
initialize(java.lang.String virtualName)
|
protected boolean |
isCreator()
|
FIFOResult |
open(FIFOImpl.PipeDirection direction)
|
int |
read(byte[] buffer,
int offset,
int length)
|
int |
read(byte[] buffer,
int offset,
int length,
int timeoutMsec)
|
void |
readNonBlocking(FIFOResult result,
byte[] buffer,
int start,
int length,
int timeoutMsec)
|
void |
select(FIFOResult result,
int timeoutMsec)
Determine if the FIFO is ready for reading, writing, or both. |
protected void |
setActualName(java.lang.String actualName)
|
protected void |
setBufferSize(int bufferSize)
|
void |
setCreator(boolean creator)
|
protected void |
setDirection(FIFOImpl.PipeDirection direction)
|
protected void |
setHandle(long handle)
|
void |
setVirtualName(java.lang.String virtualName)
|
static java.lang.String |
toActualName(java.lang.String virtualName)
Return a name that the underlying OS can use for a named pipe, given a string that is more or less unique. |
int |
write(byte[] buffer,
int offset,
int length,
int timeoutMsec)
Try to write a buffer of data within the specified time frame. |
void |
writeNonBlocking(FIFOResult result,
byte[] buffer,
int start,
int length,
int timeoutMsec)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DIRECTION_READER
public static final int DIRECTION_WRITER
public static final int BLOCKING_MODE_BLOCKING
public static final int BLOCKING_MODE_NON_BLOCKING
public static final int SELECT_READING
public static final int SELECT_WRITING
public static final int SELECT_BOTH
Constructor Detail |
---|
public FIFOImpl(java.lang.String virtualName)
Method Detail |
---|
protected void initialize(java.lang.String virtualName)
public FIFOResult create() throws IPCException
IPCException
public int write(byte[] buffer, int offset, int length, int timeoutMsec) throws IPCException
It is possible for a FIFO to have enough data written to it that it runs out of buffer space. When that happens the writer must wait until the reader reads enough of the data to free up some more buffer space.
The timeout specifies how long the caller is willing to wait for buffer space to free up. A value of less than 0 means that the caller will wait "forever." A value of 0 means that the caller will not wait at all --- if it is not possible to write immediately, then throw a timeout.
Any other value specifies the number of milliseconds that the caller will wait for the space to free up.
Note that a wait will only occur if the FIFO is full --- in all other situations, the write will complete without delay.
buffer
- The buffer that contains the data to write.offset
- The offset within the buffer that the data starts.length
- The number of bytes to try and write.timeoutMsec
- See description. The number of milliseconds to wait for a
write to become possible.
IPCException
- If the caller specified a wait time and this elapsed before
anything could be written, then this exception is thrown.public int read(byte[] buffer, int offset, int length) throws IPCException
IPCException
public int read(byte[] buffer, int offset, int length, int timeoutMsec) throws IPCException
IPCException
public FIFOResult open(FIFOImpl.PipeDirection direction) throws IPCException
IPCException
public java.lang.String getVirtualName()
public void setVirtualName(java.lang.String virtualName)
protected int getBufferSize()
protected void setBufferSize(int bufferSize)
protected java.lang.String getActualName()
protected FIFOImpl.PipeDirection getDirection()
protected int getDirectionInt()
protected long getHandle()
protected void setActualName(java.lang.String actualName)
public void setCreator(boolean creator)
protected void setDirection(FIFOImpl.PipeDirection direction)
protected void setHandle(long handle)
protected boolean isCreator()
public void createNonBlocking(FIFOResult result, java.lang.String name)
public void readNonBlocking(FIFOResult result, byte[] buffer, int start, int length, int timeoutMsec)
public void writeNonBlocking(FIFOResult result, byte[] buffer, int start, int length, int timeoutMsec)
public static java.lang.String toActualName(java.lang.String virtualName)
Currently, all platforms that support named pipes use a file name to identify the named pipe. This method does several things. First of all, it signals to CLIPC whether or not the OS uses special names for pipes.
Windows, for example, requires that all named pipes occur in the directory, "\\.\pipe" whereas linux has no such requirement.
If the underlying OS has a special naming requirement, then it should return a name that it can use, given a suffix string.
On windows, for example, if one were to supply "123456" as the suffix, the method should return "\\.\pipe\123456"
If the underlying OS does not have a special naming requirement, then it should return null. Therefore on linux, this method should return null.
suffix
- A string that the actual name should be based on. See description for
details.
public void connectNonBlocking(FIFOResult result)
public void select(FIFOResult result, int timeoutMsec)
This method is similar to the old Unix select system call, which would look for file handles read to read/write.
The call takes the amount of time the caller wants to wait for I/O to be ready on the FIFO. A value of less than 0 means wait until ready. A value of 0 means poll the FIFO but do not wait. Any other value is the number of milliseconds to wait for the FIFO to be ready.
If the client is the reader, then the method will wait until data is ready. If the client is a writer, it will wait for writing to become non-blocking.
timeouitMsec
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |