Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #606

Design for shared data

From ittium <ittium@gmail.com>
Newsgroups comp.lang.c++, comp.programming.threads
Subject Design for shared data
Date 2011-09-25 12:17 +0530
Organization A noiseless patient Spider
Message-ID <j5miqi$mu6$1@dont-email.me> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


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

Back to comp.programming.threads | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Design for shared data ittium <ittium@gmail.com> - 2011-09-25 12:17 +0530
  Re: Design for shared data Qi <no@no.com> - 2011-09-25 16:45 +0800
    Re: Design for shared data Marcel Müller <news.5.maazl@spamgourmet.org> - 2011-09-25 15:14 +0200
      Re: Design for shared data ittium <ittium@gmail.com> - 2011-09-25 20:23 +0530
  Re: Design for shared data Paavo Helde <myfirstname@osa.pri.ee> - 2011-09-25 06:05 -0500

csiph-web