summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2015-11-26 10:15:31 +0100
committerMurray Cumming <murrayc@murrayc.com>2015-11-26 10:24:43 +0100
commit68f0cdac60e5a7c7a567301cea877e49ffd7cbd5 (patch)
treec685426d8f901a63c629d5ecc8a7b4cd729407ca /examples
parente60f9a07618deff695e3487b5032bf5c480495b5 (diff)
downloadglibmm-68f0cdac60e5a7c7a567301cea877e49ffd7cbd5.tar.gz
thread example: Use std::unique_ptr<> with std::thread.
As suggested by Andrew Potter: https://bugzilla.gnome.org/show_bug.cgi?id=757674#c9
Diffstat (limited to 'examples')
-rw-r--r--examples/thread/thread.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/examples/thread/thread.cc b/examples/thread/thread.cc
index 33c37b8c..e99de76b 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;