Learning different approaches to implement concurrent programs
Now that we have understood the benefits of concurrent programming over the sequential approach, it is beneficial for you to understand a couple of other ways to deal with spawning concurrent tasks in V. So far, the programming examples we've looked at have dealt with void functions. In the following sections, we will learn how to write concurrent code for anonymous functions and how to retrieve the results from the functions that have return values.
Spawning functions with return values to run concurrently
Till now, we have spawned tasks that do not return any value to the main thread to run concurrently. We accessed the handle to these concurrent tasks and waited for these tasks to finish. What if the concurrent task has a return value? In this section, we will alter the example of morning routines that we looked at in the preceding section, where we ran void functions concurrently.
Let's consider the...