[glibmm] thread example: Use std::unique_ptr<> with std::thread.



commit 68f0cdac60e5a7c7a567301cea877e49ffd7cbd5
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Nov 26 10:15:31 2015 +0100

    thread example: Use std::unique_ptr<> with std::thread.
    
    As suggested by Andrew Potter:
    https://bugzilla.gnome.org/show_bug.cgi?id=757674#c9

 examples/thread/thread.cc |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/examples/thread/thread.cc b/examples/thread/thread.cc
index 33c37b8..e99de76 100644
--- a/examples/thread/thread.cc
+++ b/examples/thread/thread.cc
@@ -111,23 +111,21 @@ int main(int, char**)
 
   MessageQueue queue;
 
-  auto *const producer = new std::thread(
+  //TODO: Use std::make_unique() when we use C++14:
+  const auto producer = std::unique_ptr<std::thread>(new std::thread(
     [&queue] ()
     {
       queue.producer();
-    });
+    }));
 
-  auto *const consumer = new std::thread(
+   const auto consumer = std::unique_ptr<std::thread>(new std::thread(
     [&queue] ()
     {
       queue.consumer();
-    });
+    }));
 
   producer->join();
-  delete producer;
-
   consumer->join();
-  delete consumer;
 
   std::cout << std::endl;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]