chromium/cc/raster/task.h

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_RASTER_TASK_H_
#define CC_RASTER_TASK_H_

#include <stdint.h>

#include <string>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "cc/cc_export.h"

namespace cc {
class Task;

// This class provides states to manage life cycle of a task and given below is
// how it is used by TaskGraphWorkQueue to process life cycle of a task.
// Task is in kNew state when it is created. When task is added to
// |ready_to_run_tasks| then its state is changed to kScheduled. Task can be
// canceled from kNew state (not yet scheduled to run) or from kScheduled state,
// when new ScheduleTasks() is triggered and its state is changed to kCanceled.
// When task is about to run it is added |running_tasks| and its state is
// changed to kRunning. Once task finishes running, its state is changed to
// kFinished. Both kCanceled and kFinished tasks are added to |completed_tasks|.
//                ╔═════╗
//         +------║ kNew║------+
//         |      ╚═════╝      |
//         v                   v
//   ┌───────────┐        ╔══════════╗
//   │ kScheduled│------> ║ kCanceled║
//   └───────────┘        ╚══════════╝
//         |
//         v
//    ┌─────────┐         ╔══════════╗
//    │ kRunning│-------> ║ kFinished║
//    └─────────┘         ╚══════════╝
class CC_EXPORT TaskState {};

// A task which can be run by a TaskGraphRunner. To run a Task, it should be
// inserted into a TaskGraph, which can then be scheduled on the
// TaskGraphRunner.
class CC_EXPORT Task : public base::RefCountedThreadSafe<Task> {};

// A task dependency graph describes the order in which to execute a set
// of tasks. Dependencies are represented as edges. Each node is assigned
// a category, a priority and a run count that matches the number of
// dependencies. Priority range from 0 (most favorable scheduling) to UINT16_MAX
// (least favorable). Categories range from 0 to UINT16_MAX. It is up to the
// implementation and its consumer to determine the meaning (if any) of a
// category. A TaskGraphRunner implementation may chose to prioritize certain
// categories over others, regardless of the individual priorities of tasks.
struct CC_EXPORT TaskGraph {};

}  // namespace cc

#endif  // CC_RASTER_TASK_H_