All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----utah.npm.core.ThreadIPC
Summary |
final class ThreadIPC extends java.lang.Object { // Fields 32 private static final boolean AM_RECEIVER; private static final boolean AM_SENDER; static final byte IPC_OP_ACK; static final byte IPC_OP_CONNECT; private static final byte IPC_OP_INVALID; static final byte IPC_OP_OVER; static final byte IPC_OP_RECV; static final byte IPC_OP_REPLY; static final byte IPC_OP_SEND; static final byte IPC_OP_WAIT; static final int RC_DISCONNECTED; static final int RC_INVALIDDEST; static final int RC_MOREDATA; static final int RC_MOREOBJS; static final int RC_MOREREFS; static final int RC_OK; static final int RC_RESTART; private final Link clientLink_; private byte clientOps_; IPCPayload clientPayload_; Object clientPortAlias_; PortSet clientPortSet_; private boolean clientSendTo_; private Thread client_; private Thread psetQueue_; private final Link serverLink_; private byte serverOps_; IPCPayload serverPayload_; Object serverPortAlias_; PortSet serverPortSet_; private boolean serverSendTo_; private Thread server_; // Constructors 1 ThreadIPC(); // Methods 24 int clientAlert(Thread); int clientConnect(Thread); void clientDisconnectServer(Thread); int clientFindServer(Thread, boolean); int clientOps(Thread, IPCPayload, int); int clientReliableTransfer(Thread, Thread, IPCPayload, IPCPayload); int clientReverseConnection(Thread, Thread); String debugInfo(); void destroy(); boolean getClient(Link); boolean getServer(Link); void makeDormant(Thread, Thread); void makeLive(Thread, Thread); Thread s_psetDequeue(); void s_psetEnqueue(Thread); int serverAlert(Thread); int serverConnect(Thread); void serverDisconnectClient(Thread); int serverFindClient(Thread, boolean); int serverOps(Thread, IPCPayload, int); int serverReliableTransfer(Thread, Thread, IPCPayload, IPCPayload); int serverReverseConnection(Thread, Thread); void setClient(Link, boolean); void setServer(Link, boolean); }
The thread-specific IPC state and all of the methods for manipulating that state (basically, everything to with IPC.) Users of the NPM package see the IPC API through IPC.class. That class establishes a connection between two threads, this class implements the connection between two threads.
Instances of this class are visible to arbitrary subclasses of Thread, and so *all* data members and member functions must be either private or package-access only.
See Also: IPC, Thread
Fields |
· IPC_OP_CONNECT | Summary | Top |
static final byte IPC_OP_CONNECT
· IPC_OP_ACK | Summary | Top |
static final byte IPC_OP_ACK
· IPC_OP_SEND | Summary | Top |
static final byte IPC_OP_SEND
· IPC_OP_WAIT | Summary | Top |
static final byte IPC_OP_WAIT
· IPC_OP_OVER | Summary | Top |
static final byte IPC_OP_OVER
· IPC_OP_RECV | Summary | Top |
static final byte IPC_OP_RECV
· IPC_OP_REPLY | Summary | Top |
static final byte IPC_OP_REPLY
· IPC_OP_INVALID | Summary | Top |
private static final byte IPC_OP_INVALID
· RC_OK | Summary | Top |
static final int RC_OK
Return code used by all integer-returning functions. Indicates success.
· RC_RESTART | Summary | Top |
static final int RC_RESTART
Return code used to indicate that the clientOps()/serverOps() function should be restarted (usually indicated that the caller was put to sleep and when it awakes, the other half may have completed a big chunk of the operation. This code is never returned to the "user".
· RC_DISCONNECTED | Summary | Top |
static final int RC_DISCONNECTED
Return code indicating that the connection has been terminated, the caller receiving this code should clean up and exit.
· RC_INVALIDDEST | Summary | Top |
static final int RC_INVALIDDEST
Return code indicating that the destination the thread was trying to connect to has gone stale.
· RC_MOREDATA | Summary | Top |
static final int RC_MOREDATA
Return code used to indicate that the receiver should try to recieve more data (all of the sender's data didn't fit in the provided buffers).
· RC_MOREREFS | Summary | Top |
static final int RC_MOREREFS
Return code used to indicate that the receiver should try to recieve more references (all of the sender's references didn't fit in the provided buffers).
· RC_MOREOBJS | Summary | Top |
static final int RC_MOREOBJS
Return code used to indicate that the receiver should try to recieve more objects (all of the sender's objects didn't fit in the provided buffers).
· client_ | Summary | Top |
private Thread client_
If connection is "live" this will point directly to the client thread. If the connection is "dormant" or doesn't exist at all this will be null.
· clientLink_ | Summary | Top |
private final Link clientLink_
If a connection is "live", this link is invalid (there is always a link object here, but it may or may not point to something.) If the connection is "dormant" this link points to the client thread. If there is no connection, this link is null.
· clientSendTo_ | Summary | Top |
private boolean clientSendTo_
clientSendTo_ indicates what direction this thread is communicating in with its client (sending or receiving.)
· AM_SENDER | Summary | Top |
private static final boolean AM_SENDER
· AM_RECEIVER | Summary | Top |
private static final boolean AM_RECEIVER
· clientOps_ | Summary | Top |
private byte clientOps_
The set of ops we're executing as a client, e.g., on our server link. This is visible so that our server may modify it, as it completes operations for us...
· serverPayload_ | Summary | Top |
IPCPayload serverPayload_
The payload structure to use when this thread is the "server".
· clientPortAlias_ | Summary | Top |
Object clientPortAlias_
The alias associated with the port the server's current client used. This is for passing the alias info out to the server IPC layer.
· clientPortSet_ | Summary | Top |
PortSet clientPortSet_
The port set the server should block on when doing a waitReceive. This gets set in serverSetup, and should stay constant until the next setup.
· server_ | Summary | Top |
private Thread server_
Same as client_ (above) but for the server.
· serverLink_ | Summary | Top |
private final Link serverLink_
Same as clientLink_ (above) but for the server.
· serverSendTo_ | Summary | Top |
private boolean serverSendTo_
Same as clientSendTo_ (above) but for the server.
· serverPortSet_ | Summary | Top |
PortSet serverPortSet_
Port set to look for a server on. This is, effectively, the Port Ref pararmeter passed into clientConnect*().
· serverPortAlias_ | Summary | Top |
Object serverPortAlias_
Alias of the port client connected through, this is copied over into the clientPortAlias_ when a connection is set up between a client and a server.
· clientPayload_ | Summary | Top |
IPCPayload clientPayload_
The payload structure to use when this thread is the "client".
· serverOps_ | Summary | Top |
private byte serverOps_
The set of ops we're executing as a server. This is visible so that our client may modify it, as it completes operations for us...
· psetQueue_ | Summary | Top |
private Thread psetQueue_
The next thread in the queue of threads waiting on a particular PortSet.
See Also: PortSet, PortSet.s_waitForServerThread, PortSet.s_captureServerThread, PortSet.s_waitForClientThread, PortSet.s_captureClientThread
Constructors |
· ThreadIPC | Summary | Top |
ThreadIPC()
Methods |
· makeDormant | Summary | Top |
void makeDormant(Thread client, Thread server)
Make an existing, "live" connection a "dormant" one. It is always the case that the client or the server is captured by the other. Which is which is not important.
Parameter Description client the Client of the connection. server the Server of the connection.
· makeLive | Summary | Top |
void makeLive(Thread client, Thread server)
Make an existing "dormant" conneciton "live." It is always the case that the client or the server is captured by the other.
Parameter Description client the Client of the connection. server the Server of the connection.
· clientReverseConnection | Summary | Top |
int clientReverseConnection(Thread client, Thread server)
Reverse the direction of the current connection. Assumes client is the current thread (though it may be either sending or receiving.)
If the client is the sender, then it had best be trying to do an 'OVER'. If the client is the receiver then it has best be trying to do an 'ACK'. If the server is not waiting in the required state IPC_SR_ACK, or IPC_SR_OVER (respectively) then the client will block in IPC_CL_OVER or IPC_CL_ACK (respectively.)
Parameter Description client the current thread, acting as a client server the server thread for this client's connection
- Returns:
- a standard integer status return code
· clientReliableTransfer | Summary | Top |
int clientReliableTransfer(Thread client, Thread server, IPCPayload from, IPCPayload to)
Make a reliable IPC transfer between client and server, where the client is the currently running thread (and the server is "captured.")
Java-based IPC has the interesting property that the sender can never fault during the transfer. Really. Never. Makes this code much simpler.
Parameter Description client the current thread and the client in the connection server the server in the connection from the source payload (might be either client or server!) to the destination payload
- Returns:
- a standard integer status reture code
See Also: IPCPayload.tansfer
· clientFindServer | Summary | Top |
int clientFindServer(Thread client, boolean expectSendTo)
"Find" the server thread for the client's current server connection. This function assumes a connection has already been established and that it is probably "dormant." The connection is made "live." The
server_
variable is set if the server is found, otherwise it is null'd. Returns RC_OK if everything is okay, otherwise returns an appropriate non-zero error---which in all cases means disconnect.
Parameter Description client The client thread (current thread) expectSendTo true if the client is expected to be the sender
- Returns:
- RC_OK if server was found, error code otherwise.
· clientDisconnectServer | Summary | Top |
void clientDisconnectServer(Thread client)
Disconnect from server (client is caller.) Since client thread is not captured---its running---the link must be "dormant", if it exists at all. State of the server is therefore unknown. (Clients never issue a "connect" in the middle of a multi-part IPC operation, as opposed to servers which can initiate a "wait" in the middle of a multi-sequence operation.)
Parameter Description client the current thread, the client
See Also: IPC.clientDisconnect, ThreadIPC.serverDisconnectClient
· clientAlert | Summary | Top |
int clientAlert(Thread client)
Send a alert to this thread's server (the current thread is the client.)
Parameter Description client the current thread acting as a client
- Returns:
- an standard integer status return code.
· clientConnect | Summary | Top |
int clientConnect(Thread client)
Connect the given client to some server on serverPortSet_. If no server is available, the client will be blocked in IPC_CL_CONNECT. If a server is available, that server will be captured, and links between client and server will be made "live" (direct.) If the client blocks, when it wakes, it may have been captured by the server which might have completed all the client's operations for it.
Sets the
server_
member variable.
Parameter Description client the client thread (also the current thread)
- Returns:
- RC_OK if the client should proceed (it didn't block), some other return code if the client was blocked and potentially captured.
· clientOps | Summary | Top |
int clientOps(Thread client, IPCPayload payload, int initialOps)
Perform a set of operations on a connection as the client.
Invariants: server_ is null when entering and exiting this function.
Parameter Description client the current thread acting as a client in an IPC. payload the data to send as a request (if any) and the buffers to receive replys into (if any) initialOps a bit flag of the various IPC operations to perform.
- Returns:
- a standard integer status return code
· setClient | Summary | Top |
void setClient(Link newlink, boolean sendTo)
Set the client link for to this thread's client pointer to the provided link.
Parameter Description newLink a link to the new client to point to sendTo a boolean flag indicating the direction of the transfer to the newLink client.
· getClient | Summary | Top |
boolean getClient(Link link)
Get the current client link for this thread's client connection and the direction of the transfer.
Parameter Description link this link is set to point to the current client thread
- Returns:
- the current direction of the transfer (true for sending, false for receiving)
· serverReverseConnection | Summary | Top |
int serverReverseConnection(Thread server, Thread client)
Reverse the direction of the current connection. Assumes server is the current thread (though it may be either sending or receiving.
If the server is the sender, then it had best be trying to do an 'OVER'. If the server is the receiver then it has best be trying to do an 'ACK'. If the client is not waiting in the required state IPC_CL_ACK, or IPC_CL_OVER (respectively) then the server will block in IPC_SR_OVER or IPC_SR_ACK (respectively.)
Parameter Description server the current thread, acting as an IPC server client the current thread's client thread.
- Returns:
- a standard integer status return code
· serverDisconnectClient | Summary | Top |
void serverDisconnectClient(Thread server)
Disconnect from client (server is caller.) Since server thread is not captured---its running---the link may be non-existant, dormant or live. State of the client is therefore unknown.
Parameter Description server the current thread, the server
See Also: IPC.serverDisconnect, ThreadIPC.clientDisconnectServer
· serverAlert | Summary | Top |
int serverAlert(Thread server)
Send an alert to the current thread's client. TODO: Not implemented
Parameter Description server the current thread acting as a server thread
- Returns:
- a standard integer return code
· serverReliableTransfer | Summary | Top |
int serverReliableTransfer(Thread server, Thread client, IPCPayload from, IPCPayload to)
Make a reliable IPC transfer between server and client, where the server is the currently running thread (and the client is "captured.")
Java-based IPC has the interesting property that the sender can never fault during the transfer. Really. Never. Makes this code much simpler.
Parameter Description server the current thread and the server in the connection client the client in the connection from the source payload (might be either server's or client's!) to the destination payload
- Returns:
- a standard integer status return code
See Also: IPCPayload.transfer
· serverFindClient | Summary | Top |
int serverFindClient(Thread server, boolean expectSendTo)
"Find" the client thread for the server's current client connection. This function assumes a connection has already been established and that it is probably "dormant." The connection is made "live." The
client_
variable is set if the client is found, otherwise it is null'd. Returns RC_OK if everything is okay, otherwise returns an appropriate non-zero error---which in all cases means disconnect.
Parameter Description server The server thread (current thread) expectedSender true if the server is expected to be the sender
- Returns:
- RC_OK if client was found, error code otherwise.
· serverConnect | Summary | Top |
int serverConnect(Thread server)
Connect the given server to some client on clientPortSet_. If no client is available, the server will be blocked in IPC_CL_CONNECT. If a client is available, that client will be captured, and links between server and client will be made "live" (direct.) If the server blocks, when it wakes, it may have been captured by the client which might have completed all the server's operations for it.
Sets the
client_
member variable.
Parameter Description server the server thread (also the current thread)
- Returns:
- RC_OK if the server should proceed (it didn't block), some other return code if the server was blocked and potentially captured.
· serverOps | Summary | Top |
int serverOps(Thread server, IPCPayload payload, int initialOps)
Perform a set of operations on a connection as the server.
Invariants: client_ is null when entering and exiting this function.
Parameter Description server the current thread acting as an IPC server payload the buffers to receive client requests in (if any) and the data to send as a reply (if any) initialOps the set of IPC operations to perform.
- Returns:
- a standard integer status return code
· setServer | Summary | Top |
void setServer(Link newlink, boolean sendTo)
Set the server link for to this thread's server pointer to the provided link.
Parameter Description newLink a link to the new server to point to sendTo a boolean flag indicating the direction of the transfer to the newLink server.
· getServer | Summary | Top |
boolean getServer(Link link)
Get the current server link for this thread's server connection and the direction of the transfer.
Parameter Description link this link is set to point to the current server thread
- Returns:
- the current direction of the transfer (true for sending, false for receiving)
· s_psetEnqueue | Summary | Top |
void s_psetEnqueue(Thread next)
Enqueue this thread in a pset queue. The thread object passed in is the first thread of the rest of the queue. The current thread will become the head of the queue.
Parameter Description next the first thread of the rest of the port set queue.
See Also: PortSet.s_waitForServerThread, PortSet.s_waitForClientThread
· s_psetDequeue | Summary | Top |
Thread s_psetDequeue()
Dequeue this thread from the list of threads blocked on a PortSet. Returns the head of the rest of the queue.
- Returns:
- the first Thread on the remainder of the PortSet queue.
See Also: PortSet.s_captureClientThread, PortSet.s_captureServerThread
· destroy | Summary | Top |
void destroy()
Destroy the IPC state of this thread. This is only ever called by the destroy() method on Thread.
See Also: Thread.destroy
· debugInfo | Summary | Top |
String debugInfo()
Generate a string describing the state of the IPC this thread is involved in.
- Returns:
- a string describing the state of the IPC state.
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7