|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Ibis abstraction for data to be written.
A WriteMessage
is obtained from a SendPort
through
the SendPort.newMessage
method.
At most one WriteMessage
is alive at one time for a given
SendPort.
When a message is alive and a new message is requested, the requester
is blocked until the live message is finished.
For all write methods in this class, the invariant is that the reads must
match the writes one by one. The only exception to this rule is that an
array written with any of the writeArray
methods can be
read by ReadMessage.readObject
.
In particular, an array written with writeObject
cannot be read with readArray
, because
writeObject
does duplicate detection, and may
have written only a handle.
Method Summary | |
long |
finish()
If needed, send, and then block until the entire message has been sent and clear the message. |
void |
finish(java.io.IOException e)
This method can be used to inform Ibis that one of the WriteMessage methods has thrown an IOException. |
SendPort |
localPort()
Returns the SendPort of this WriteMessage . |
void |
reset()
Resets the state of any objects already written to the stream. |
int |
send()
Starts sending the message to all ReceivePorts its SendPort is connected to. |
void |
sync(int ticket)
Blocks until the data of the send which returned
the ticket parameter may be used again. |
void |
writeArray(boolean[] val)
Writes an array of booleans to the message. |
void |
writeArray(boolean[] val,
int off,
int len)
Writes a slice of an array of booleans. |
void |
writeArray(byte[] val)
Writes an array of bytes to the message. |
void |
writeArray(byte[] val,
int off,
int len)
Write a slice of an array of bytes. |
void |
writeArray(char[] val)
Writes an array of chars to the message. |
void |
writeArray(char[] val,
int off,
int len)
Write a slice of an array of chars. |
void |
writeArray(double[] val)
Writes an array of doubles to the message. |
void |
writeArray(double[] val,
int off,
int len)
Write a slice of an array of doubles. |
void |
writeArray(float[] val)
Writes an array of floats to the message. |
void |
writeArray(float[] val,
int off,
int len)
Write a slice of an array of floats. |
void |
writeArray(int[] val)
Writes an array of ints to the message. |
void |
writeArray(int[] val,
int off,
int len)
Write a slice of an array of ints. |
void |
writeArray(long[] val)
Writes an array of longs to the message. |
void |
writeArray(long[] val,
int off,
int len)
Write a slice of an array of longs. |
void |
writeArray(java.lang.Object[] val)
Writes an array of objects to the message. |
void |
writeArray(java.lang.Object[] val,
int off,
int len)
Write a slice of an array of objects. |
void |
writeArray(short[] val)
Writes an array of shorts to the message. |
void |
writeArray(short[] val,
int off,
int len)
Write a slice of an array of shorts. |
void |
writeBoolean(boolean val)
Writes a boolean value to the message. |
void |
writeByte(byte val)
Writes a byte value to the message. |
void |
writeChar(char val)
Writes a char value to the message. |
void |
writeDouble(double val)
Writes a double value to the message. |
void |
writeFloat(float val)
Writes a float value to the message. |
void |
writeInt(int val)
Writes a int value to the message. |
void |
writeLong(long val)
Writes a long value to the message. |
void |
writeObject(java.lang.Object val)
Writes a Serializable object to the message. |
void |
writeShort(short val)
Writes a short value to the message. |
void |
writeString(java.lang.String val)
Writes a String to the message. |
Method Detail |
public int send() throws java.io.IOException
ReceivePorts
its SendPort
is connected to.
Data may be streamed, so the user is not allowed to change the data
pushed into this message, as the send is NON-blocking.
It is only safe to touch the data after it has actually been
sent, which can be ensured by either calling finish()
or
reset()
, or a sync(int)
corresponding to this send.
The send
method returns a ticket, which can be used
as a parameter to the sync(int)
method, which will block until
the data corresponding to this ticket can be used again.
java.io.IOException
- an error occurredpublic void sync(int ticket) throws java.io.IOException
send
which returned
the ticket
parameter may be used again.
It also synchronizes with respect to all sends before that.
If ticket
does not correspond to any send
,
it blocks until all outstanding sends have been processed.
ticket
- the ticket number.
java.io.IOException
- an error occurredpublic void reset() throws java.io.IOException
java.io.IOException
- an error occurredpublic long finish() throws java.io.IOException
java.io.IOException
- an error occurredpublic void finish(java.io.IOException e)
WriteMessage
methods has thrown an IOException.
It implies a finish()
.
e
- the exception that was thrown.public SendPort localPort()
SendPort
of this WriteMessage
.
SendPort
of this WriteMessage
.public void writeBoolean(boolean val) throws java.io.IOException
val
- the boolean value to write.
java.io.IOException
- an error occurredpublic void writeByte(byte val) throws java.io.IOException
val
- the byte value to write.
java.io.IOException
- an error occurredpublic void writeChar(char val) throws java.io.IOException
val
- the char value to write.
java.io.IOException
- an error occurredpublic void writeShort(short val) throws java.io.IOException
val
- the short value to write.
java.io.IOException
- an error occurredpublic void writeInt(int val) throws java.io.IOException
val
- the int value to write.
java.io.IOException
- an error occurredpublic void writeLong(long val) throws java.io.IOException
val
- the long value to write.
java.io.IOException
- an error occurredpublic void writeFloat(float val) throws java.io.IOException
val
- the float value to write.
java.io.IOException
- an error occurredpublic void writeDouble(double val) throws java.io.IOException
val
- the double value to write.
java.io.IOException
- an error occurredpublic void writeString(java.lang.String val) throws java.io.IOException
String
to the message.
A duplicate check for this String
object
is performed: if the object was already written to this
message, a handle for this object is written instead of
the object itself.
val
- the string to write.
java.io.IOException
- an error occurredpublic void writeObject(java.lang.Object val) throws java.io.IOException
Serializable
object to the message.
A duplicate check for this String
object
is performed: if the object was already written to this
message, a handle for this object is written instead of
the object itself.
val
- the object value to write.
java.io.IOException
- an error occurredpublic void writeArray(boolean[] val) throws java.io.IOException
writeArray(val, 0, val.length);
(See writeArray(boolean[], int, int)
).
val
- the array to be written.
java.io.IOException
- an error occurredpublic void writeArray(byte[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(char[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(short[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(int[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(long[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(float[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(double[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(java.lang.Object[] val) throws java.io.IOException
writeArray(boolean[])
for a description.
java.io.IOException
public void writeArray(boolean[] val, int off, int len) throws java.io.IOException
off
No duplicate check is performed for this array!
- Parameters:
val
- the array to be writtenoff
- offset in the arraylen
- the number of elements to be written
- Throws:
java.io.IOException
- an error occurred
public void writeArray(byte[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
public void writeArray(char[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
public void writeArray(short[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
public void writeArray(int[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
public void writeArray(long[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
public void writeArray(float[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
public void writeArray(double[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
public void writeArray(java.lang.Object[] val, int off, int len) throws java.io.IOException
writeArray(boolean[], int, int)
for a description.
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |