|
|
|
|
4.12 Last-Only Stress-Flow CallsOften we are interested in just most recent information, or a most recent set of data. Consider a program that redraws complex shape in response to mouse movements. There is not enough time and it would not make sense to redraw the shape every one pixel movement of the mouse, especially if the computer has its resources used up by something more important. On the other hand, sampling it arbitrarily, say every predetermined amount of time, will limit responsiveness. Similar issue exists in instrumentation and signal processing application. Our FIG. 12 example most likely would be a candidate for something like that as well. Suppose the output device is much slower compared to the input. In such a case, if lots of data was fed into the system, a queue of values to output would build up and it would grow, which would mean that after a while, we would be outputting extremely old data while building up backlog of new data waiting at stress atom locks. Even if such a problem could not usually occur by guaranteeing proper speed characteristics of inputs and outputs, it is a good practice to make sure in software that something like that cannot happen. In the particular case of instrumentation signal processing application, letting the most recent data through ASAP is generally much more desirable than trying to process and output all data samples. In particular, if the output is for human eyes, the last value is all that is desired.
FIG. 17: Code from FIG. 13 using last-only stress flow atoms Suppose we were to modify the “ordered” stress-flow atom mechanisms in a way that would discard all older scheduled requests to a specific stress-flow atom the moment the completed (not just reserved) newer call has arrived. This is very easy to accomplish, and pretty much the only thing to do is create a new definition designator for such type of an atom. As before, rather that reserve another keyword, we can just use the question mark instead of the exclamation mark in the listing of atoms to be called in ordered fashion. See FIG. 17. From now on, this new type of stress-flow atom call will be referred to as “last-only” call. |
|