]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Undo r29899. I now know where to look.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 28 Jun 2013 03:41:24 +0000 (03:41 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 28 Jun 2013 03:41:24 +0000 (03:41 +0000)
git-svn-id: https://svn.dealii.org/trunk@29900 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/work_stream.h

index 8e2ade6d7160d3c73d59362554d1047c912b5a35..3a98da2afa9bda122079a4bc6d9322419d1d0daf 100644 (file)
@@ -19,7 +19,6 @@
 #include <deal.II/base/template_constraints.h>
 #include <deal.II/base/std_cxx1x/function.h>
 #include <deal.II/base/std_cxx1x/bind.h>
-#include <deal.II/base/thread_local_storage.h>
 
 #ifdef DEAL_II_WITH_THREADS
 #  include <deal.II/base/thread_management.h>
@@ -157,8 +156,8 @@ namespace WorkStream
        */
       typedef
       std_cxx1x::tuple<std::vector<Iterator>,
-                Threads::ThreadLocalStorage<ScratchData>*,
-               std::vector<CopyData>,
+                ScratchData *,
+                std::vector<CopyData>,
                 unsigned int>
                 ItemType;
 
@@ -181,7 +180,6 @@ namespace WorkStream
         tbb::filter (/*is_serial=*/true),
         remaining_iterator_range (begin, end),
         ring_buffer (buffer_size),
-                       thread_local_scratch(sample_scratch_data),
         n_emitted_items (0),
         chunk_size (chunk_size)
       {
@@ -196,10 +194,20 @@ namespace WorkStream
           tasks += Threads::new_task (&IteratorRangeToItemStream::init_buffer_elements,
                                       *this,
                                       i,
+                                      std_cxx1x::cref(sample_scratch_data),
                                       std_cxx1x::cref(sample_copy_data));
         tasks.join_all ();
       }
 
+      /**
+       * Destructor.
+       */
+      ~IteratorRangeToItemStream ()
+      {
+        for (unsigned int i=0; i<ring_buffer.size(); ++i)
+          delete std_cxx1x::get<1>(ring_buffer[i]);
+      }
+
       /**
        * Create a item and return a
        * pointer to it.
@@ -252,12 +260,6 @@ namespace WorkStream
       std::vector<ItemType>        ring_buffer;
 
       /**
-                                         * Scratch data object. Each thread will
-                                         * have its own local copy.
-                                         */
-       Threads::ThreadLocalStorage<ScratchData> thread_local_scratch;
-
-                                        /**
        * Counter for the number of emitted
        * items. Each item may consist of up
        * to chunk_size iterator elements.
@@ -284,6 +286,7 @@ namespace WorkStream
        * the ring buffer.
        */
       void init_buffer_elements (const unsigned int element,
+                                 const ScratchData &sample_scratch_data,
                                  const CopyData    &sample_copy_data)
       {
         Assert (std_cxx1x::get<1>(ring_buffer[element]) == 0,
@@ -292,7 +295,7 @@ namespace WorkStream
         std_cxx1x::get<0>(ring_buffer[element])
         .resize (chunk_size, remaining_iterator_range.second);
         std_cxx1x::get<1>(ring_buffer[element])
-               = &thread_local_scratch;
+          = new ScratchData(sample_scratch_data);
         std_cxx1x::get<2>(ring_buffer[element])
         .resize (chunk_size, sample_copy_data);
       }
@@ -351,7 +354,7 @@ namespace WorkStream
            try
              {
                worker (std_cxx1x::get<0>(*current_item)[i],
-                     std_cxx1x::get<1>(*current_item)->get(),
+                       *std_cxx1x::get<1>(*current_item),
                        std_cxx1x::get<2>(*current_item)[i]);
              }
            catch (const std::exception &exc)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.