title: Limitation on Qt and boost thread local storage
body: <p>I have following questions on QThreadStorage and boost's thread_specific_ptr:</p>
  
  <p>1) Is there any limitation on number of objects that can be stored in Qthreadstorage? I came across a qt query about 256 QThreadStorage objects, so like to clarify what this limitation points to?</p>
  
  <p>2) Does QThreadStorage work only with QThreads?</p>
  
  <p>3) Is there any limitation on boost tls?</p>
  
  <p>4) I have a use case where I want to operate on tls and sync the data to main thread when all threads finish for further processing. I wrote the below code and like to check if the below code is okay.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/thread/thread.hpp&gt;
  #include &lt;boost/thread/tss.hpp&gt;
  
  boost::mutex mutex1;
  int glob = 0;
  
  class data
  {
      public:
      char* p;
      data()
      {
              p = (char*)malloc(10);
          sprintf(p, "test%d\n", ++glob);
      }
  };
  
  char* global_p[11] = {0}; 
  int index = -1;
  
  void cleanup(data* _ignored) {
      std::cout &lt;&lt; "TLS cleanup" &lt;&lt; std::endl;
  boost::mutex::scoped_lock lock(mutex1);
  global_p[++index] = _ignored-&gt;p;
  }
  
  
  
  boost::thread_specific_ptr&lt;data&gt; value(cleanup);
  
  void thread_proc()
  {
      value.reset(new data()); // initialize the thread's storage
  std::cout &lt;&lt; "here" &lt;&lt; std::endl;
  }
  
  int main(int argc, char* argv[])
  {
      boost::thread_group threads;
      for (int i=0; i&lt;10; ++i)
          threads.create_thread(&amp;thread_proc);
      threads.join_all();
  
      for (int i=0; i&lt;10; ++i)
          puts(global_p[i]);
  }
  </code></pre>