Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,207 of 33,346    |
|    =?ISO-8859-1?Q?=D6=F6_Tiib?= to All    |
|    Re: Returning a char* pointer    |
|    15 Sep 13 23:07:44    |
   
   From: ootiib@hot.ee   
      
   On Saturday, 14 September 2013 14:01:47 UTC+3, fmatthew5876 wrote:   
   > > If that is the only problem for you then there are   
   > > compiler-specific extensions ('__thread', '__declspec( thread )')   
   > > or third party libs ('boost::thread_specfic_ptr<>') to make the   
   > > idiom thread safe again.   
   >   
   > I'm not sure its a good idea to just throw thread local variables   
   > all over the place. Every thread local variable you create adds to   
   > the memory overhead of each thread. If everyone was doing this then   
   > we would have to pay a lot of memory for functions most threads may   
   > not even call.   
      
   Everything costs something, there are several solutions and it is one   
   option to weight. There is typically TLS table and compiler-dependent   
   limits to it. If thread local storage will be used massively then   
   there will be errors of exceeding the limits.   
      
   One possible workaround is to make only a pointer thread-local and   
   allocate real buffer (or whole tree of such buffers) lazily on first   
   demand. The threads that do not use the buffer won't have it, only a   
   potential pointer to it.   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca