O'Reilly logo

Mastering Android NDK by Viktor Latypov, Sergey Kosarevsky

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

Task queues

To process a logical piece of work, we will declare the iTask class with the Run() method, which can perform a time-consuming operation. The declaration of the class is somewhat visually similar to iThread. However, its instances implement some reasonably short operation and may be executed in different threads:

  class iTask: public iIntrusiveCounter
  {
  public:
    iTask()
    : FIsPendingExit( false )
    , FTaskID( 0 )
    , FPriority( 0 )
    {};

The pure virtual method Run() should be overridden in subclasses to do the actual work:

    virtual void Run() = 0;

The following methods optionally cancel the task and are similar to the ones in the iThread class. Their purpose is to signal the hosting thread that this task should be cancelled:

 virtual void Exit() ...

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