The class LocalTill acts as an interface between a Channel and the
CentralResource, allowing the existing CentralResource classtobe
used without modification. At the heart of the class, requests are
repeatedly removed from the Channel, processed, and responses placed
on the Channel.
\begin{vdm_al} class LocalTill
\end{vdm_al}
Since it acts as an interface, the LocalTill has references to the two
objects it mediates between: a Channel and the CentralResource. In
addition a boolean value is used to represent whether the communication
has failed ornot (this is used for modelling purposes, allowing us to
test behaviour of the overall model in the presence of failed communication).
The heart of this classis its thread, so we being by describing it.
The thread repeatedly receives requests from the Channel and processes them, as long as enabled istrue. Note that due to the synchronization constraints in Channel, the call to c.ReceiveRequest will block until a request has been
sent by a Till. Also, as well as the looping condition there is a second
check of enabled in the body of the loop in case it has changed while the thread was waitingfor a request.
\begin{vdm_al} thread while enabled do letreq = c.ReceiveRequest() in if enabled then ProcessRequest(req);
\end{vdm_al}
As can be seen from the thread, the main operation in this classis
ProcessRequest. This takes a request, converts it into a call to the
CentralResource, then converts the resultfrom CentralResource into a
response and sends this to the Channel. Of course the call to CentralResource
will depend upon the kind of request made, so a case statement is used to
distinguish these requests.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.