title: OpenMp: Threadlocal member
body: <p>I am currently working on a piece of code written by a former colleague which utilizes OpenMP. Myself however has no experience with OpenMP and while I understand the very basics by just reading his code, I'm currently stuck figuring out how to declare a threadlocal member for my own modification.</p>
  <p>The current code in a very simplified version looks like this:</p>
  <pre><code>struct Worker
  {
      void work() { //... }
  };
  
  -------------------------------------------------------------------
  
  Worker worker;
  
  #pragma omp parallel for
  for (int i = 0; i &lt; n; ++i)
  {
      worker.work();
  }
  </code></pre>
  <p>What I want to acheive is to modify the <code>Worker</code> class in a way similiar to this:</p>
  <pre><code>struct Worker
  {
      void work() { // m_var is accessed here }
      
      int m_var; // should be threadlocal
  };
  </code></pre>
  <p>However I have no clue how to achieve this using OpenMP. Notice that all other members inside <code>Worker</code> should not be synchronized or threadlocal.</p>
  <p>PS: For those who are curious, <code>Worker</code> is actually a class to download some complicated stuff and in the for loop the single downloads are performed. <code>m_var</code> is going to be an object holding a session.</p>