Getting Started with Drupal QueueWorker and Cron
In Drupal there are the QueueWorker
and QueueWorkerManager
classes that are helpful in managing a queue. One benefit of managing tasks is a queue is they offer a way of managing tasks or jobs in an orderly way. Think First in First Out.
The way the QueueWorker in Drupal works is tied in with cron.
Lets have a look at the run function in web/core/lib/Drupal/Core/Cron.php