public final class EClient extends java.lang.ref.WeakReference<EObject> implements java.lang.Comparable<EClient>
EClientties together eBus message routing and message processing. eBus views an application instance in three ways: 1) an implementation of one or more eBus interfaces (publisher, subscriber, requester, or replier), 2) the owner of open feeds and 3) the target of callback
EClientstores the instance's open feeds and un-executed callback tasks.
eBus has a client-oriented execution mode rather than
task-oriented. When the client's task list is not empty, the
EClient instance is placed on a run queue where it
appears only once.
Dispatcher threads remove
clients from this run queue and execute the client's tasks.
Dispatcher continues executing the client's
tasks until the client task queue or run quantum is exhausted.
When the nanosecond run quantum reaches zero, the client is
appended to the run queue if it has pending tasks.
The run quantum reset to the configurable initial quantum
value when a dispatcher thread acquires the client. Note: when
the run quantum expires, eBus cannot preempt the client. It is
possible for the client to run indefinitely, taking over the
EClient maintains a weak reference to the application
instance. When eBus detects that the application instance is
finalized, all feeds left open by the instance are closed. If
the application instance is a replier, then all active
requests will receive an error reply. The client's un-executed
tasks are cleared.
EClientmaintains one or more
Dispatchergroups where each group has a separate run queue. Each client is assigned to an executor group based on the encapsulated application class. If the application class is not assigned to a particular executor group, then the class is assigned to the default executor group. The executor groups are defined via
configuration. If no executors are defined, then there is one
Dispatcherthread for each
coreusing a single, blocking run queue. Executors block until there is an runnable
EClientposted to group run queue. As stated previously, an
EClientis assigned to only one client dispatcher thread at a time. This makes an
EClientinstance effectively single-threaded if that client is accessed only by dispatcher threads. While a client may be accessed by different dispatcher threads over time, it will be accessed by only one at any given moment in time.
EClient is assigned a integer identifier which is
guaranteed unique for the client lifespan. When the client
is disposed, the client identifier is re-used and may be
assigned to a new, future eBus client instance. An
EClient is disposed when the encapsulated application
instance is finalized.
The reason for
EClient is because eBus requires
application objects to
implement interfaces in order
to interface with eBus, not
eBus abstract class. This class provides the functionality
that an abstract client class would provide.
|Modifier and Type||Class and Description|
An eBus client is either local to this JVM or in a remote JVM.
|Modifier and Type||Method and Description|
Returns an integer value <, equal to, or > zero based on whether
Returns the unique client identifier as the hash code.
public int compareTo(EClient client)
this EClientinstance's identifier is <, equal to, or >
client- comparison object.
public boolean equals(java.lang.Object o)
ois a non-
null EClientinstance with the same client identifier as
thisinstance; otherwise, returns
o- comparison object.
trueif the client identifiers are equal.
public int hashCode()
public java.lang.String toString()
public static void dispatch(java.lang.Runnable task, EObject client)
client's task queue (this is the same task queue used for eBus message delivery). If the task queue was originally empty, then the client posted to its run queue for execution by a
client is unknown to eBus, then a new
EClient instance will be created with a
weak reference to
client does not need to be an eBus
task- post to the client task queue.
taskis for this client.
java.lang.NullPointerException- if either