From 9772c6b20671235a148a22b141af31bc3afd0844 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 17 May 2024 16:34:52 -0500 Subject: [PATCH 01/11] Add draft for build systems --- .../modules/compilation-model/buildsystems.md | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 sources/modules/compilation-model/buildsystems.md diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md new file mode 100644 index 0000000..7fa4159 --- /dev/null +++ b/sources/modules/compilation-model/buildsystems.md @@ -0,0 +1,110 @@ +## Module name: Build systems + +_Skeleton descriptions are typeset in italic text,_ +_so please don't remove these descriptions when editing the topic._ + +### Overview + +_Provides a short natural language abstract of the module’s contents._ +_Specifies the different levels of teaching._ + +------------------------------------------------------------------------ +Level Objective +----------------- ------------------------------------------------------ +Foundational --- Knowledge about build systems + +Main --- Usage of build system to compile a executable + +Advanced --- Usage of build system to compile a library or + add external libraries as a dependencies + +------------------------------------------------------------------------ + +### Motivation + +_Why is this important?_ +_Why do we want to learn/teach this topic?_ + +* Building complex C++ projects by hand or writing Make files is tricky +* Build systems can help to resolve dependencies +* Build systems can help do distribute C++ code and help other to compile the code +* Build systems can help to find and include libraries as dependencies +* All major C++ projects are distributed with build systems + +### Topic introduction + +_Very brief introduction to the topic._ + +Build systems are used to configure, build, and install complex C++ projects. + + +### Foundational: Knowledge about build systems + +#### Background/Required Knowledge + +A student: +* Should know about build systems + + +#### Student outcomes + +_A list of things "a student should be able to" after the curriculum._ +_The next word should be an action word and testable in an exam._ +_Max 5 items._ + +A student should be able to: + +1. To explain what a build system is +2. Know that a build systems resolves dependencies +3. Know that a build system support cross-platform compilation + +#### Caveats + +_This section mentions subtle points to understand, like anything resulting in +implementation-defined, unspecified, or undefined behavior._ + +None + +#### Points to cover + +_This section lists important details for each point._ + +* Mention that many build systems are available for C++. +* Mention benefits and challenges + +### Main: Usage of build system to compile a executable + +#### Background/Required Knowledge + +* All of the above. + +#### Student outcomes + +A student should be able to: + +1. Write a configuration file to compile a C++ program with a main method +2. Use the build system to generate the executable + +#### Caveats + +The instructions are restricted to the chosen build system and +not easily transferable. + + +#### Points to cover + +* Adding include paths to header files +* Adding compiler flags +* How to build Release and Debug builds + + +### Advanced + +_These are important topics that are not expected to be covered but provide +guidance where one can continue to investigate this topic in more depth._ + +* How to build libraries +* How to include libraries to the executable +* How to find external libraries and include them +* How to add support for different compilers +* How to add support for different operating systems From ac383ec48c5a4b208f60ebd6123821084529c909 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Fri, 26 Jul 2024 09:46:54 -0600 Subject: [PATCH 02/11] Update buildsystems.md Discussion with the US group --- .../modules/compilation-model/buildsystems.md | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md index 7fa4159..55e43a3 100644 --- a/sources/modules/compilation-model/buildsystems.md +++ b/sources/modules/compilation-model/buildsystems.md @@ -25,11 +25,12 @@ Advanced --- Usage of build system to compile a library or _Why is this important?_ _Why do we want to learn/teach this topic?_ -* Building complex C++ projects by hand or writing Make files is tricky +* Building complex C++ projects by hand is tricky * Build systems can help to resolve dependencies * Build systems can help do distribute C++ code and help other to compile the code * Build systems can help to find and include libraries as dependencies -* All major C++ projects are distributed with build systems +* Build systems faciliate project management +* All major C++ projects are distributed with build systems ### Topic introduction @@ -43,7 +44,7 @@ Build systems are used to configure, build, and install complex C++ projects. #### Background/Required Knowledge A student: -* Should know about build systems +* Should know how to compile and link C++ programs #### Student outcomes @@ -55,8 +56,8 @@ _Max 5 items._ A student should be able to: 1. To explain what a build system is -2. Know that a build systems resolves dependencies -3. Know that a build system support cross-platform compilation +2. To explain a build systems resolves dependencies +3. To explain a build system supports compilation for different operating systems and architectures #### Caveats @@ -69,8 +70,9 @@ None _This section lists important details for each point._ -* Mention that many build systems are available for C++. +* Mention that many build systems are available for C++ * Mention benefits and challenges +* Build system help to only compile the C++ files with code changes and not the complete project ### Main: Usage of build system to compile a executable @@ -82,8 +84,10 @@ _This section lists important details for each point._ A student should be able to: -1. Write a configuration file to compile a C++ program with a main method -2. Use the build system to generate the executable +1. Download a C++ package and build the package +2. Write a configuration file to compile a C++ executable +3. Pass compiler options via the build system +4. Use the build system to generate the executable #### Caveats @@ -96,6 +100,8 @@ not easily transferable. * Adding include paths to header files * Adding compiler flags * How to build Release and Debug builds +* Linking external libraries to the C++ project +* Support different operating systems, compilers, and architectures ### Advanced @@ -103,8 +109,7 @@ not easily transferable. _These are important topics that are not expected to be covered but provide guidance where one can continue to investigate this topic in more depth._ -* How to build libraries -* How to include libraries to the executable -* How to find external libraries and include them -* How to add support for different compilers -* How to add support for different operating systems +* How to build libraries +* Write a configuration file for your own library +* How to have external libraries be downloaded during the build process + From ecbec3b702563e64f9249d9f9dfc15bc99d5822f Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Thu, 26 Sep 2024 09:28:18 -0600 Subject: [PATCH 03/11] Typos --- sources/modules/compilation-model/buildsystems.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md index 55e43a3..fd6a97d 100644 --- a/sources/modules/compilation-model/buildsystems.md +++ b/sources/modules/compilation-model/buildsystems.md @@ -56,8 +56,8 @@ _Max 5 items._ A student should be able to: 1. To explain what a build system is -2. To explain a build systems resolves dependencies -3. To explain a build system supports compilation for different operating systems and architectures +2. To explain that a build systems resolves dependencies +3. To explain that a build system supports compilation for different operating systems and architectures #### Caveats From 646500521c217714e8b29b15961b58c6b37cb2b1 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Thu, 26 Sep 2024 09:29:22 -0600 Subject: [PATCH 04/11] More typos --- sources/modules/compilation-model/buildsystems.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md index fd6a97d..85e11d4 100644 --- a/sources/modules/compilation-model/buildsystems.md +++ b/sources/modules/compilation-model/buildsystems.md @@ -97,7 +97,7 @@ not easily transferable. #### Points to cover -* Adding include paths to header files +* Include paths to header files to the configuration * Adding compiler flags * How to build Release and Debug builds * Linking external libraries to the C++ project From f50e498b4aabf030e44ae061d310ed79a02f6d44 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Sun, 20 Oct 2024 21:00:59 -0600 Subject: [PATCH 05/11] Update buildsystems.md Mention unit testing --- sources/modules/compilation-model/buildsystems.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md index 85e11d4..5bd0fc0 100644 --- a/sources/modules/compilation-model/buildsystems.md +++ b/sources/modules/compilation-model/buildsystems.md @@ -112,4 +112,5 @@ guidance where one can continue to investigate this topic in more depth._ * How to build libraries * Write a configuration file for your own library * How to have external libraries be downloaded during the build process +* Mention that build systems provide support for unit testing From 430c317b53ce1a2950ff8859c554b5365fcf7c4b Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Sun, 20 Oct 2024 21:06:50 -0600 Subject: [PATCH 06/11] Update buildsystems.md Move building a lib and link it to a C++ executable to the main level --- sources/modules/compilation-model/buildsystems.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md index 5bd0fc0..7666771 100644 --- a/sources/modules/compilation-model/buildsystems.md +++ b/sources/modules/compilation-model/buildsystems.md @@ -88,6 +88,7 @@ A student should be able to: 2. Write a configuration file to compile a C++ executable 3. Pass compiler options via the build system 4. Use the build system to generate the executable +5. Write a configuration file to compile a library and link the library to a C++ executable #### Caveats @@ -110,7 +111,6 @@ _These are important topics that are not expected to be covered but provide guidance where one can continue to investigate this topic in more depth._ * How to build libraries -* Write a configuration file for your own library * How to have external libraries be downloaded during the build process * Mention that build systems provide support for unit testing From ee55d0e2b732f281e0ce70687d48e10e65e87d55 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Sun, 20 Oct 2024 21:08:42 -0600 Subject: [PATCH 07/11] Update buildsystems.md --- sources/modules/compilation-model/buildsystems.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md index 7666771..5b5e4ac 100644 --- a/sources/modules/compilation-model/buildsystems.md +++ b/sources/modules/compilation-model/buildsystems.md @@ -15,8 +15,7 @@ Foundational --- Knowledge about build systems Main --- Usage of build system to compile a executable -Advanced --- Usage of build system to compile a library or - add external libraries as a dependencies +Advanced --- Add external libraries as a dependencies ------------------------------------------------------------------------ @@ -88,7 +87,7 @@ A student should be able to: 2. Write a configuration file to compile a C++ executable 3. Pass compiler options via the build system 4. Use the build system to generate the executable -5. Write a configuration file to compile a library and link the library to a C++ executable +5. Write a configuration file to compile a library and link the library to a C++ executable #### Caveats From cbbfbe2c3abd5beff8301c1277b3bc621496fd0b Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Thu, 31 Oct 2024 09:05:06 -0600 Subject: [PATCH 08/11] make it more precise --- sources/modules/compilation-model/buildsystems.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/modules/compilation-model/buildsystems.md b/sources/modules/compilation-model/buildsystems.md index 5b5e4ac..8e14fa0 100644 --- a/sources/modules/compilation-model/buildsystems.md +++ b/sources/modules/compilation-model/buildsystems.md @@ -101,7 +101,7 @@ not easily transferable. * Adding compiler flags * How to build Release and Debug builds * Linking external libraries to the C++ project -* Support different operating systems, compilers, and architectures +* Support compilation on different operating systems, compilers, and architectures ### Advanced From 6b27d2172b742027412e8a9d826dc1fdf0c5b1d6 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Thu, 17 Apr 2025 11:54:56 -0600 Subject: [PATCH 09/11] Draft --- .../async-programming.md | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 sources/modules/concurrency-parallelism/async-programming.md diff --git a/sources/modules/concurrency-parallelism/async-programming.md b/sources/modules/concurrency-parallelism/async-programming.md new file mode 100644 index 0000000..49c3340 --- /dev/null +++ b/sources/modules/concurrency-parallelism/async-programming.md @@ -0,0 +1,124 @@ +## Module name: Asynchronous programming + +_Skeleton descriptions are typeset in italic text,_ +_so please don't remove these descriptions when editing the topic._ + +### Overview + +_Provides a short natural language abstract of the module’s contents._ +_Specifies the different levels of teaching._ + +------------------------------------------------------------------------ +Level Objective +----------------- ------------------------------------------------------ +Foundational --- Knowledge about build systems + +Main --- Usage of build system to compile a executable + +Advanced --- Add external libraries as a dependencies + +------------------------------------------------------------------------ + +### Motivation + +_Why is this important?_ +_Why do we want to learn/teach this topic?_ + +* Asynchronous programming allows for non-blocking functions launches and enables that functions are executed asynchronoulsy. +* Asynchronous programming is one form of parallism and concurrency included in the C++ standard + +### Topic introduction + +_Very brief introduction to the topic._ + +Build systems are used to configure, build, and install complex C++ projects. + + +### Foundational: Knowledge about build systems + +#### Background/Required Knowledge + +A student: +* Should know [lambdas](../functions/lambdas.md) + +#### Student outcomes + +_A list of things "a student should be able to" after the curriculum._ +_The next word should be an action word and testable in an exam._ +_Max 5 items._ + +A student should be able to: + +1. To explain what asynchronous programming is +2. To explain what a futures and promise are + +#### Caveats + +_This section mentions subtle points to understand, like anything resulting in +implementation-defined, unspecified, or undefined behavior._ + +None + +#### Points to cover + +_This section lists important details for each point._ + +* Mention how to launch a function or lambda asynchronously using `std::async` +* Mention how to use a `std::future` as a place holder for the result + +### Main: Launch functions asynchronous and obtain the results + +#### Background/Required Knowledge + +* All of the above. + +#### Student outcomes + +A student should be able to: + +1. Do define a function or lambda for the computational task +2. Launch the function or lambda asynchronous and obtain the results + +#### Caveats + +The concept of asyncrhonous programming is no easy digestiable for most students. + + +#### Points to cover + +* The header `` needs to be includes +* The return type of the function or lambda will the the template type of the future +* The first argument of `std::async` is the function or lambda and after that all arguments are providesd + +Example using a function +``` +void print_square(double a) +{ + std::cout << "Result=" << a * a << std::endl; +} + +std::future f = std::async(print,5.0); +// We could do other work here +f.get() +``` + +Example using lambdas +``` +// Compute the sum +std::future f1 = std::async([](double a, double b){ return a + b;}); +// Compute the square +std::future f2 = std::async([](double a){ return a * a;}); + +// Gather the results and add them up +double res = f1.get() + f2.get(); +``` + +### Advanced + +_These are important topics that are not expected to be covered but provide +guidance where one can continue to investigate this topic in more depth._ + +* How to build libraries +* How to have external libraries be downloaded during the build process +* Mention that build systems provide support for unit testing + From 5ec7833a76ea23b3947510f7765af3668595c699 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Thu, 17 Apr 2025 12:28:11 -0600 Subject: [PATCH 10/11] Typos --- .../modules/concurrency-parallelism/async-programming.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sources/modules/concurrency-parallelism/async-programming.md b/sources/modules/concurrency-parallelism/async-programming.md index 49c3340..97371f7 100644 --- a/sources/modules/concurrency-parallelism/async-programming.md +++ b/sources/modules/concurrency-parallelism/async-programming.md @@ -24,8 +24,8 @@ Advanced --- Add external libraries as a dependencies _Why is this important?_ _Why do we want to learn/teach this topic?_ -* Asynchronous programming allows for non-blocking functions launches and enables that functions are executed asynchronoulsy. -* Asynchronous programming is one form of parallism and concurrency included in the C++ standard +* Asynchronous programming allows for non-blocking functions launches and enables that functions are executed asynchronously. +* Asynchronous programming is one form of parallelism and concurrency included in the C++ standard ### Topic introduction @@ -81,14 +81,14 @@ A student should be able to: #### Caveats -The concept of asyncrhonous programming is no easy digestiable for most students. +The concept of asynchronous programming is no easy digestible for most students. #### Points to cover * The header `` needs to be includes * The return type of the function or lambda will the the template type of the future -* The first argument of `std::async` is the function or lambda and after that all arguments are providesd +* The first argument of `std::async` is the function or lambda and after that all arguments are provided Example using a function ``` From 44f42be778e14d21a83db208481610e4b7ff6349 Mon Sep 17 00:00:00 2001 From: Patrick Diehl Date: Thu, 29 Oct 2026 09:39:15 -0600 Subject: [PATCH 11/11] Update advanced topics --- .../async-programming.md | 179 ++++++++++++------ 1 file changed, 116 insertions(+), 63 deletions(-) diff --git a/sources/modules/concurrency-parallelism/async-programming.md b/sources/modules/concurrency-parallelism/async-programming.md index 97371f7..b395042 100644 --- a/sources/modules/concurrency-parallelism/async-programming.md +++ b/sources/modules/concurrency-parallelism/async-programming.md @@ -1,124 +1,177 @@ -## Module name: Asynchronous programming +## # Module name: Asynchronous programming -_Skeleton descriptions are typeset in italic text,_ -_so please don't remove these descriptions when editing the topic._ +*Skeleton descriptions are typeset in italic text,* +*so please don't remove these descriptions when editing the topic.* ### Overview -_Provides a short natural language abstract of the module’s contents._ -_Specifies the different levels of teaching._ +*Provides a short natural language abstract of the module’s contents.* +*Specifies the different levels of teaching.* ------------------------------------------------------------------------- -Level Objective ------------------ ------------------------------------------------------ -Foundational --- Knowledge about build systems +Asynchronous programming allows computational tasks to execute independently of the calling code, potentially enabling concurrent execution and improving responsiveness. C++ provides standard library facilities such as `std::async`, `std::future`, and `std::promise` to launch tasks, communicate results, and synchronize execution. -Main --- Usage of build system to compile a executable +This module introduces the fundamental concepts of asynchronous programming and demonstrates how to launch functions and lambdas asynchronously and retrieve their results. -Advanced --- Add external libraries as a dependencies - ------------------------------------------------------------------------- +| Level | Objective | +|---|---| +| Foundational | Understand asynchronous programming, futures, and promises. | +| Main | Launch functions and lambdas asynchronously and retrieve their results. | +| Advanced | Understand synchronization, exception handling, and more advanced asynchronous programming techniques. | ### Motivation -_Why is this important?_ -_Why do we want to learn/teach this topic?_ +*Why is this important?* +*Why do we want to learn/teach this topic?* -* Asynchronous programming allows for non-blocking functions launches and enables that functions are executed asynchronously. -* Asynchronous programming is one form of parallelism and concurrency included in the C++ standard +- Asynchronous programming allows tasks to be launched without requiring the calling code to wait immediately for their completion. +- Asynchronous programming enables concurrency and potentially parallel execution, which can improve application responsiveness and resource utilization. +- The C++ standard library provides mechanisms for asynchronous task execution, result retrieval, and synchronization. ### Topic introduction -_Very brief introduction to the topic._ +*Very brief introduction to the topic.* -Build systems are used to configure, build, and install complex C++ projects. +Asynchronous programming allows a function or lambda to be launched while the calling code continues executing other operations. The result of an asynchronous computation can be retrieved later when it becomes available. +C++ provides `std::async` to launch tasks and `std::future` to access their results. A future represents a value that may not yet be available. Calling `get()` retrieves the result, waiting for the computation to complete if necessary. -### Foundational: Knowledge about build systems +### Foundational: Understanding asynchronous programming #### Background/Required Knowledge -A student: -* Should know [lambdas](../functions/lambdas.md) +A student: + +- Should understand functions and their return values. +- Should know [lambdas](../functions/lambdas.md). #### Student outcomes -_A list of things "a student should be able to" after the curriculum._ -_The next word should be an action word and testable in an exam._ -_Max 5 items._ +*A list of things "a student should be able to" after the curriculum.* +*The next word should be an action word and testable in an exam.* +*Max 5 items.* A student should be able to: -1. To explain what asynchronous programming is -2. To explain what a futures and promise are +1. Explain the concept of asynchronous programming. +2. Distinguish between synchronous and asynchronous execution. +3. Explain the purpose of futures and promises. +4. Identify the roles of `std::async` and `std::future` in asynchronous programming. #### Caveats -_This section mentions subtle points to understand, like anything resulting in -implementation-defined, unspecified, or undefined behavior._ +*This section mentions subtle points to understand, like anything resulting in implementation-defined, unspecified, or undefined behavior.* -None +- Asynchronous execution does not necessarily imply parallel execution. +- Retrieving a result from a future may block until the computation completes. +- The default execution policy of `std::async` does not guarantee that a task executes asynchronously. #### Points to cover -_This section lists important details for each point._ +*This section lists important details for each point.* -* Mention how to launch a function or lambda asynchronously using `std::async` -* Mention how to use a `std::future` as a place holder for the result +- Introduce synchronous and asynchronous execution. +- Explain how `std::async` launches functions or lambdas. +- Introduce `std::future` as a placeholder for a result that becomes available later. +- Explain the distinction between `std::future` and `std::promise`. +- Introduce the concept of waiting for an asynchronous computation to complete. -### Main: Launch functions asynchronous and obtain the results +### Main: Launching asynchronous functions and retrieving results #### Background/Required Knowledge -* All of the above. +- All of the above. #### Student outcomes A student should be able to: -1. Do define a function or lambda for the computational task -2. Launch the function or lambda asynchronous and obtain the results +1. Define a function or lambda representing a computational task. +2. Launch a function or lambda asynchronously using `std::async`. +3. Retrieve the result of an asynchronous computation using `std::future::get()`. +4. Launch multiple independent asynchronous tasks and combine their results. +5. Explain the differences between the `std::launch::async` and `std::launch::deferred` execution policies. #### Caveats -The concept of asynchronous programming is no easy digestible for most students. - +- `std::future::get()` blocks until the result is available and can be called only once for a given future. +- `std::async` may execute tasks immediately or defer their execution, depending on the selected launch policy. +- Using `std::launch::async` explicitly ensures asynchronous execution. +- Asynchronous tasks accessing shared mutable data require appropriate synchronization to avoid data races. +- Destruction of a future returned by `std::async` may block until the asynchronous task finishes. #### Points to cover -* The header `` needs to be includes -* The return type of the function or lambda will the the template type of the future -* The first argument of `std::async` is the function or lambda and after that all arguments are provided +- Include the `` header to use `std::async` and `std::future`. +- Explain how to launch functions and lambdas using `std::async`. +- Explain how `std::launch::async` requests asynchronous execution. +- Explain that the return type of the function or lambda determines the template argument of `std::future`. +- Explain that `std::async` accepts a callable followed by its arguments, optionally preceded by an execution policy. +- Explain how to retrieve a result using `get()` and why this operation may block. +- Demonstrate how multiple asynchronous tasks can execute independently before their results are combined. -Example using a function -``` -void print_square(double a) +**Example using a function** + +```cpp +#include +#include + +double square(double a) { - std::cout << "Result=" << a * a << std::endl; + return a * a; } -std::future f = std::async(print,5.0); -// We could do other work here -f.get() -``` +int main() +{ + std::future f = + std::async(std::launch::async, square, 5.0); + + // Perform other work while square is computed. -Example using lambdas + std::cout << "Result = " << f.get() << '\n'; +} ``` -// Compute the sum -std::future f1 = std::async([](double a, double b){ return a + b;}); -// Compute the square -std::future f2 = std::async([](double a){ return a * a;}); -// Gather the results and add them up -double res = f1.get() + f2.get(); +**Example using lambdas** + +```cpp +#include +#include + +int main() +{ + // Compute the sum asynchronously. + std::future f1 = std::async( + std::launch::async, + [](double a, double b) { return a + b; }, + 2.0, 3.0 + ); + + // Compute the square asynchronously. + std::future f2 = std::async( + std::launch::async, + [](double a) { return a * a; }, + 4.0 + ); + + // Perform other work while tasks execute. + + // Retrieve and combine the results. + double res = f1.get() + f2.get(); + + std::cout << "Result = " << res << '\n'; +} ``` -### Advanced +### Advanced: Managing asynchronous execution -_These are important topics that are not expected to be covered but provide -guidance where one can continue to investigate this topic in more depth._ +*These are important topics that are not expected to be covered but provide* +*guidance where one can continue to investigate this topic in more depth.* -* How to build libraries -* How to have external libraries be downloaded during the build process -* Mention that build systems provide support for unit testing +#### Topics for further study +- **Execution policies:** Compare `std::launch::async` and `std::launch::deferred` and their implications for execution. +- **Futures and promises:** Use `std::promise` to communicate results between threads and `std::shared_future` to allow multiple consumers to access a result. +- **Synchronization:** Explore `std::future::wait()`, `wait_for()`, and `wait_until()`. +- **Exception handling:** Understand how exceptions thrown during asynchronous execution are propagated through `std::future::get()`. +- **Thread safety:** Investigate data races, shared state, and synchronization mechanisms. +- **Task composition:** Explore techniques for coordinating dependent asynchronous computations and alternatives such as coroutines and task-based runtimes.