
Task Based Programming Over Thread Base
Prefer Task based Programming to Thread-Based If you want to run something Async you have two basic choices: std::thread and std::async int doAsyncWork(); std::thread th(doAsyncWork); // Better to use Async auto future = std::async(doAsyncWork); std::async(doAsyncWork) is considered a task. The task is superior because it returns a future value which we can use to sync up our program. Async task also has a get function which we can use to get the status and or if our work function emits an exception. Async task also provides more abstraction. What is the meaning of Thread? Hardware threads, perform computation. Contemporary machine architectures offer one or more hardware threads per CPU core. Software threads (also known as OS threads or system threads) are the threads that the operating system manages across all processes and schedules for execution on hardware threads. std::threads are objects in a C++ process that act as handles to underlying software threads. Software threads are
Continue reading on Dev.to
Opens in a new tab

