From 576bc7f0998f9e55aab22b526cde29ff727680d3 Mon Sep 17 00:00:00 2001 From: ITHelpDec <34002836+ITHelpDec@users.noreply.github.com> Date: Sun, 11 Jun 2023 13:37:21 +0100 Subject: [PATCH 1/2] correct naming of threadsafe_stack - there is only one instance of "thread_safe_stack" in the entire book (this example) - in every other instance, the container is named "threadsafe_stack" (only one underscore) --- listings/listing_8.1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listings/listing_8.1.cpp b/listings/listing_8.1.cpp index f47f5a6..19d7886 100644 --- a/listings/listing_8.1.cpp +++ b/listings/listing_8.1.cpp @@ -11,7 +11,7 @@ struct sorter std::promise > promise; }; - thread_safe_stack chunks; + threadsafe_stack chunks; std::vector threads; unsigned const max_thread_count; std::atomic end_of_data; From 50b7e43748af7ef91b39f4a742ca32735ebb897d Mon Sep 17 00:00:00 2001 From: ITHelpDec <34002836+ITHelpDec@users.noreply.github.com> Date: Sun, 11 Jun 2023 13:57:41 +0100 Subject: [PATCH 2/2] opt for `std::shared_ptr<>` over `boost::shared_ptr<>` - listing 6.1 does not use boost::shared_ptr<> (there don't seem to be any other instances of boost::shared_ptr<> in the book) - we can either change this or modify 6.1 (although we need to modify it anyway to prevent the throw) --- listings/listing_8.1.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/listings/listing_8.1.cpp b/listings/listing_8.1.cpp index 19d7886..41647bc 100644 --- a/listings/listing_8.1.cpp +++ b/listings/listing_8.1.cpp @@ -32,7 +32,7 @@ struct sorter void try_sort_chunk() { - boost::shared_ptr chunk=chunks.pop(); + std::shared_ptr chunk=chunks.pop(); if(chunk) { sort_chunk(chunk); @@ -79,7 +79,7 @@ struct sorter return result; } - void sort_chunk(boost::shared_ptr const& chunk) + void sort_chunk(std::shared_ptr const& chunk) { chunk->promise.set_value(do_sort(chunk->data)); }