Download Restrained re-engineering

Transcript
Table 3.
Function declarations available in the HC-Sim callback interface.
Function declaration
Purpose
hcsim_callback_report_started
(hcsim_callback_time_t*)
hcsim_callback_report_finished
(hcsim_callback_time_t*)
Reports back when a simulation has
started.
Reports back when a simulation has
finished.
hcsim_callback_event
(hcsim_callback_event_t,
hcsim_callback_event_parameter_t*)
Called when a simulation event has
taken place.
hcsim_callback_poll_keep_running Called to check whether the user has
(hcsim_callback_parameter_t*)
stopped the simulation.
Polling
During a simulation, HC-Sim handles a growing queue of small and separate events.
Between each event, the simulator polls HC-Sim GUI to check if the simulation has been
stopped prematurely. Using callback functions to poll the user interface for this
information is not the most efficient way to go about it. There are other ways to handle
this interaction, for instance by using signals and messages between threads. The
advantage of using polls is the simplicity of design and implementation, but one should
keep in mind that a considerable number of polls might be made during the course of a
simulation.
Simulation event callbacks
In the analysis process we stated that the functionality for providing rich information
about simulation events could be placed within HC-Sim or it could be placed externally.
The latter provides more flexibility, and adds less code to HC-Sim, and so it seems like
the best solution for our purposes.
By making HC-Sim report back to HC-Sim GUI each time an interesting event has
occurred, HC-Sim GUI can acquire the information needed to make a correct graphical
presentation and to show the current status and progress of HC-Sim. At the same time, we
eliminate the need for HC-Sim to maintain event related statistical data that would add
complexity and unnecessary quantities of code to the simulator. The callback events and
flow of data will be explained further in the Information management section (page 30).
24