C++ Concurrency Sandbox
Loading...
Searching...
No Matches
TaskWrapper Struct Reference

A functor that wraps a packaged_task shared pointer. More...

Collaboration diagram for TaskWrapper:

Public Member Functions

void operator() ()
 Executes the wrapped task.
 

Public Attributes

std::shared_ptr< std::packaged_task< void()> > ptr
 Pointer to the task.
 

Detailed Description

A functor that wraps a packaged_task shared pointer.

  • This wrapper allows the worker threads to execute a task by calling its operator(), effectively hiding the specific return type of the underlying std::packaged_task from the worker loop.

Definition at line 42 of file ThreadPool_Advanced.cpp.

Member Function Documentation

◆ operator()()

void TaskWrapper::operator() ( )
inline

Executes the wrapped task.

Definition at line 48 of file ThreadPool_Advanced.cpp.

48 {
49 if (ptr) (*ptr)();
50 }
std::shared_ptr< std::packaged_task< void()> > ptr
Pointer to the task.

References ptr.

Member Data Documentation

◆ ptr

std::shared_ptr<std::packaged_task<void()> > TaskWrapper::ptr

Pointer to the task.

Definition at line 43 of file ThreadPool_Advanced.cpp.

Referenced by operator()().


The documentation for this struct was generated from the following file: