You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These are from omnetpp(5.6.2) simulation document.
4.4.3 How to Avoid Global Variables
If possible, avoid using global variables, including static class members. They are prone to
cause several problems. First, they are not reset to their initial values (to zero) when you
rebuild the simulation in Tkenv/Qtenv, or start another run in Cmdenv. This may produce
surprising results. Second, they prevent you from parallelizing the simulation. When using
parallel simulation, each partition of the model runs in a separate process, having their own
copies of global variables. This is usually not what you want.
The solution is to encapsulate the variables into simple modules as private or protected data
members, and expose them via public methods. Other modules can then call these public
methods to get or set the values.
Calling methods of other modules will be discussed in
section 4.12. Examples of such modules are the Blackboard in the Mobility Framework, and
Global variables will be broken in parallel simulation, such as:
OPS/src/KMessengerApp.cc
Line 15 in 424d53c
The text was updated successfully, but these errors were encountered: