public interface TargetInterface
Targets, similar to
how Pipes operate.
Depending on the represented Target this may operate on none, one or
multiple pipes (when operating on registers, a port or a virtual port like
Target.ANY, respectively).
Note that unlike for pipes, write operations may finish instantly here, when
writing to a register, for example. In that case beginWrite(short)
will return true to indicate this.
| Modifier and Type | Method and Description |
|---|---|
void |
beginRead()
Begin a reading operation on the target.
|
boolean |
beginWrite(short value)
Begin a writing operation on the target.
|
boolean |
canTransfer()
Whether the target can transfer data, i.e.
|
boolean |
isReading()
Whether the target is currently being read from.
|
boolean |
isWriting()
Whether the target is currently being written to.
|
default void |
onWriteComplete(Port port)
Finish a write operation started by the instruction, usually by
advancing the program counter.
|
short |
read()
Finish a read operation by fetching the data made available from the
represented target.
|
boolean beginWrite(short value)
Make sure not to call this if the target is already being written to, or
an exception will be thrown. Use isWriting() to check for this.
value - the value to write to the target.java.lang.IllegalStateException - if the target is already being written to.boolean isWriting()
This is true as soon as beginWrite(short) was called and
until read() was called to finish or cancel the operation,
unless the operation was completed synchronously, in which case
beginWrite(short) returned true.
void beginRead()
Make sure not to call this if the target is already being read from, or
an exception will be thrown. Use isReading() to check for this.
java.lang.IllegalStateException - if the target is already being read from.boolean isReading()
This is true as soon as beginRead() was called and
until read() was called to finish the operation.
boolean canTransfer()
read() can be called.
Note that this is not equivalent to isReading() &&
isWriting(). Depending on the target type, this may be
only true in the first update after that has been true and
later, but it may also be true right away or always.
short read()
Make sure not to call this if the target is not in the correct state, or
an exception will be thrown. use canTransfer() to check for this.
java.lang.IllegalStateException - if the target is in an incorrect state.default void onWriteComplete(Port port)
Instructions must always await or cancel a write operation they started.
port - the port the interface was writing to.