Starting with version 3.0, TBB supports asynchronous task execution. To do this, a special tbb::task::enqueue() sentence method was added. Unlike tbb::task::spawn() , this method guarantees the execution of the given queue, even if the source thread never enters a method for sending the task, for example, wait_for_all() .
Short usage example for task::enqueue() :
class MyTask : public tbb::task { tbb::task* execute() {
As mentioned in a comment by @JimMishell, an example of using this function to handle GUI events can be found in "Design Patterns"; and a formal description of the method is available in the reference manual (see TBB documentation for both).
source share