So before we get started.. Let’s introduce ourselves to some workqueue jargon.
- Work item a simple struct that holds a pointer to the function
that is to be executed asynchronously.
- Work queue a queue of work items
- Worker threads Special purpose threads that execute the functions
off the queue, one after the other.
- Workerpools A thread pool that is used to manage the worker threads
We have a work item that is a simple struct that holds a pointer to the function that needs to be asynchronously executed.
A work queue is the queue to which these work items are queued.
Now, worker threads are these special purpose threads that execute the work items on the queue, one after the other.
And for managing these worker threads we have the workerpools.
This is the typical life cycle of a workqueue:
While there are work items on the workqueue the worker executes the
functions associated with the work items one after the other. When
there is no work item left on the workqueue the worker becomes idle.
When a new work item gets queued, the worker begins executing again.
And that’s all about the concept of workqueues… 😀