Class ZStar
- All Implemented Interfaces:
ZAgent
- Direct Known Subclasses:
ZActor
A side or endpoint designates the same thing: the thread where lives one of the two parts of the system.
A Star has 2 sides (with a trial to use theater terms for fun (: and hopefully clarity :)
- the Corbeille side, or control side
This is where one cansendandreceivecontrol messages to the underneath star via the ZStar agent.
The ZStar lives on this side and is a way to safely communicate with the distant provided star.
Note: Corbeille is a french word designing the most privileged places in the theater where the King was standing, 1st floor, just above the orchestra (Wikipedia...). - the Plateau side, or background side where all the performances are made by the provided star.
The provided star is living on the Plateau.
The Plateau is made of the Stage where effective acting takes place and of the Wings where the provided star can perform control decisions to stop or continue the acting.
From this side, the work is done via callbacks using the template-method pattern, applied with interfaces (?)
Communication between the 2 sides is ensured by pipes that SHALL NEVER be mixed between background and control sides.
Instead, each side use its own pipe to communicate with the other one, transmitting only ØMQ messages.
The main purpose of this class is to ease this separation and to provide contracts, responsibilities and action levers for each side.
For example, instead of using pipe() which is useful to have more control, fast users would want to call agent() to get the agent
or directly call send(ZMsg) or recv() from the ZStar as the ZStar is itself an agent!
The ZStar takes care of the establishment of the background processing, calling the provided star
at appropriate times. It can also manage the exited state on the control side,
if providing a non-null "Mot de la Fin".
It also takes care of the closing of sockets and context if it had to create one.
A star is basically a contract interface that anyone who uses this ZStar to create a background service SHALL comply to.
PS: Je sais qu'il y a une différence entre acteur et comédien :)
PPS: I know nothing about theater!
For an example of code, please refer to the ZActor source code.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceUtility class with calls surrounding the execution of the Star.static interfaceControl for the end of the remote operations.static interfaceprivate static final classstatic interfacestatic classstatic interfaceContract interface when acting in plain sight.static interfaceUtility class with callback for when the Star has finished its performances.Nested classes/interfaces inherited from interface ZAgent
ZAgent.Creator, ZAgent.SelectorCreator, ZAgent.SimpleAgent -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionZStar(ZAgent.SelectorCreator selector, ZStar.Fortune fortune, String motdelafin, Object... bags) Deprecated.ZStar(ZContext context, ZAgent.SelectorCreator selector, ZStar.Fortune fortune, String motdelafin, Object... bags) Deprecated.useZStar(ZContext, Fortune, String, Object...)instead.ZStar(ZContext context, ZAgent.SelectorCreator selector, ZStar.Fortune fortune, BiFunction<ZMQ.Socket, String, ZAgent> agent, String motdelafin, Object... bags) Deprecated.ZStar(ZContext context, ZStar.Fortune fortune, String motdelafin, Object... bags) Creates a new ZStar.ZStar(ZContext context, ZStar.Fortune fortune, BiFunction<ZMQ.Socket, String, ZAgent> agent, String motdelafin, Object... bags) Creates a new ZStar.ZStar(ZStar.Fortune fortune, String motdelafin, Object... bags) Creates a new ZStar. -
Method Summary
Modifier and TypeMethodDescriptionagent()Returns the Corbeille endpoint.protected ZAgentagent(ZMQ.Socket phone, String secret) Deprecated.voidclose()Closes the pipe.exit()Returns the control of the proper exit of the remote operations.static voidpipe()Returns the socket used for communication.recv()Receives a control message sent from the Plateau in the Corbeille.recv(boolean wait) Receives a control message sent from the Plateau in the Corbeille.recv(int timeout) Receives a control message sent from the Plateau in the Corbeille.booleanSends a control message from the Corbeille to the Plateau side.booleanSends a control message from the Corbeille to the Plateau side.booleanSends a control message from the Corbeille to the Plateau.booleanSends a control message from Corbeille side to the Plateau side.booleansign()Gives a sign if the distant Star is here.
-
Field Details
-
context
-
agent
-
plateau
-
-
Constructor Details
-
ZStar
@Deprecated public ZStar(ZAgent.SelectorCreator selector, ZStar.Fortune fortune, String motdelafin, Object... bags) Deprecated.useZStar(Fortune, String, Object...)instead.Creates a new ZStar.- Parameters:
selector- the creator of the selector used on the Plateau.fortune- the creator of stars on the Plateaumotdelafin- the final word used to mark the end of the star. Null to disable this mechanism.bags- the optional arguments that will be passed to the distant star
-
ZStar
Creates a new ZStar.- Parameters:
fortune- the creator of stars on the Plateaumotdelafin- the final word used to mark the end of the star. Null to disable this mechanism.bags- the optional arguments that will be passed to the distant star
-
ZStar
@Deprecated public ZStar(ZContext context, ZAgent.SelectorCreator selector, ZStar.Fortune fortune, String motdelafin, Object... bags) Deprecated.useZStar(ZContext, Fortune, String, Object...)instead.Creates a new ZStar.- Parameters:
context- the main context used. If null, a new context will be created and closed at the stop of the operation. If not null, it is the responsibility of the caller to close it.selector- the creator of the selector used on the Plateau.fortune- the creator of stars on the Plateaumotdelafin- the final word used to mark the end of the star. Null to disable this mechanism.bags- the optional arguments that will be passed to the distant star
-
ZStar
Creates a new ZStar.- Parameters:
context- the main context used. If null, a new context will be created and closed at the stop of the operation. If not null, it is the responsibility of the caller to close it.fortune- the creator of stars on the Plateaumotdelafin- the final word used to mark the end of the star. Null to disable this mechanism.bags- the optional arguments that will be passed to the distant star
-
ZStar
@Deprecated public ZStar(ZContext context, ZAgent.SelectorCreator selector, ZStar.Fortune fortune, BiFunction<ZMQ.Socket, String, ZAgent> agent, String motdelafin, Object... bags) Deprecated.Creates a new ZStar.- Parameters:
context- the main context used. If null, a new context will be created and closed at the stop of the operation. If not null, it is the responsibility of the caller to close it.selector- the creator of the selector used on the Plateau.fortune- the creator of stars on the Plateau. Not null.agent- the creator of the agent. Not null.motdelafin- the final word used to mark the end of the star. Null to disable this mechanism.bags- the optional arguments that will be passed to the distant star
-
ZStar
public ZStar(ZContext context, ZStar.Fortune fortune, BiFunction<ZMQ.Socket, String, ZAgent> agent, String motdelafin, Object... bags) Creates a new ZStar.- Parameters:
context- the main context used. If null, a new context will be created and closed at the stop of the operation. If not null, it is the responsibility of the caller to close it.fortune- the creator of stars on the Plateau. Not null.agent- the creator of the agent. Not null.motdelafin- the final word used to mark the end of the star. Null to disable this mechanism.bags- the optional arguments that will be passed to the distant star
-
-
Method Details
-
party
-
agent
Returns the Corbeille endpoint. Can be used to send or receive control messages to the distant star via Backstage.- Returns:
- the agent/mailbox used to send and receive control messages to and from the star.
-
exit
Returns the control of the proper exit of the remote operations.- Returns:
- a structure used for checking the end of the remote operations.
-
agent
Deprecated.Creates a new agent for the star.- Parameters:
phone- the socket used to communicate with the starsecret- the specific keyword indicating the death of the star and locking the agent. Null to override the lock mechanism.- Returns:
- the newly created agent for the star.
-
recv
-
recv
Description copied from interface:ZAgentReceives a control message sent from the Plateau in the Corbeille. The call times out if there is no message after the elapsed time. -
recv
Description copied from interface:ZAgentReceives a control message sent from the Plateau in the Corbeille. The call is blocking depending on the parameter. -
send
Description copied from interface:ZAgentSends a control message from the Corbeille to the Plateau. -
send
Description copied from interface:ZAgentSends a control message from Corbeille side to the Plateau side. -
send
Description copied from interface:ZAgentSends a control message from the Corbeille to the Plateau side. -
send
Description copied from interface:ZAgentSends a control message from the Corbeille to the Plateau side. -
pipe
Description copied from interface:ZAgentReturns the socket used for communication. For advanced usage. -
sign
-
close
-
ZStar(Fortune, String, Object...)instead.