I
ittium
Group,
I have a design a multi-threaded system that uses good amount of shared
data. This data is needed in multiple classes/functions. I have three
designs for it.
1. Keep the data global, so that it can be accessed any where
2. Wrap the data in singleton class and use it wherever needed by
getInstance static method.
3. Pass the data by constant reference where ever needed. In this case
if function is part of some function hierarchy then data will have to be
passed from topmost function to the function where it is used.
All these approaches will solve the issue. I am not able to see
advantages or disadvantages of these approaches. Any new approach is
also welcome.
Please consider the solution form the point of view of synchronization
effort, since shared data is to be used in multi-threaded solution.
thanks
ittium
I have a design a multi-threaded system that uses good amount of shared
data. This data is needed in multiple classes/functions. I have three
designs for it.
1. Keep the data global, so that it can be accessed any where
2. Wrap the data in singleton class and use it wherever needed by
getInstance static method.
3. Pass the data by constant reference where ever needed. In this case
if function is part of some function hierarchy then data will have to be
passed from topmost function to the function where it is used.
All these approaches will solve the issue. I am not able to see
advantages or disadvantages of these approaches. Any new approach is
also welcome.
Please consider the solution form the point of view of synchronization
effort, since shared data is to be used in multi-threaded solution.
thanks
ittium