O'Reilly logo

Boost C++ Application Development Cookbook by Antony Polukhin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Registering a task for processing an arbitrary datatype

First of all, let's take care of the class that will hold all the tasks and provide methods for their execution. We were already doing something like this in the Creating a work_queue class recipe, but some of the following problems were not addressed:

  • A task may throw an exception that leads a call to std::terminate
  • An interrupted thread may not notice interruption but will finish its task and interrupt only during the next task (which is not what we wanted; we wanted to interrupt the previous task)
  • Our work_queue class was only storing and returning tasks, but we need to add methods for executing existing tasks
  • We need a way to stop processing the tasks

Getting ready

This recipe requires linking ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required