]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Do not attempt to copy std::unique_ptr objects, and provide a workaround
authorMatthias Maier <tamiko@43-1.org>
Wed, 27 May 2020 00:59:52 +0000 (19:59 -0500)
committerMatthias Maier <tamiko@43-1.org>
Wed, 27 May 2020 16:26:14 +0000 (11:26 -0500)
include/deal.II/base/work_stream.h

index 4549e494c9cbacff61a44d378c8d40082d94a7d2..1d03dbf89dd1048af8650165fec81fd88283d1d4 100644 (file)
@@ -211,6 +211,13 @@ namespace WorkStream
               , currently_in_use(in_use)
             {}
 
+            // Provide a copy constructor that actually doesn't copy the
+            // internal state. This makes handling ScratchAndCopyDataObjects
+            // easier to handle with STL containers.
+            ScratchDataObject(const ScratchDataObject &)
+              : currently_in_use(false)
+            {}
+
             ScratchDataObject(ScratchDataObject &&o) noexcept = default;
           };
 
@@ -710,19 +717,11 @@ namespace WorkStream
           , currently_in_use(in_use)
         {}
 
-        // TODO: when we push back an object to the list of scratch objects, in
-        //      Worker::operator(), we first create an object and then copy
-        //      it to the end of this list. this involves having two objects
-        //      of the current type having pointers to it, each with their own
-        //      currently_in_use flag. there is probably little harm in this
-        //      because the original one goes out of scope right away again, but
-        //      it's certainly awkward. one way to avoid this would be to use
-        //      unique_ptr but we'd need to figure out a way to use it in
-        //      non-C++11 mode
-        ScratchAndCopyDataObjects(const ScratchAndCopyDataObjects &o)
-          : scratch_data(o.scratch_data)
-          , copy_data(o.copy_data)
-          , currently_in_use(o.currently_in_use)
+        // Provide a copy constructor that actually doesn't copy the
+        // internal state. This makes handling ScratchAndCopyDataObjects
+        // easier to handle with STL containers.
+        ScratchAndCopyDataObjects(const ScratchAndCopyDataObjects &)
+          : currently_in_use(false)
         {}
       };
 

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.