Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #607
| From | Qi <no@no.com> |
|---|---|
| Newsgroups | comp.lang.c++, comp.programming.threads |
| Subject | Re: Design for shared data |
| Date | 2011-09-25 16:45 +0800 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <j5mpve$shl$1@speranza.aioe.org> (permalink) |
| References | <j5miqi$mu6$1@dont-email.me> |
Cross-posted to 2 groups.
On 2011-9-25 14:47, ittium wrote: > 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. Singletons are evil http://blogs.msdn.com/b/scottdensmore/archive/2004/05/25/140827.aspx And they are more evil in multiple thread. So your 1 and 2 approached are kicked out. And 3 is the good approach, IMO. -- WQ
Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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