Files
XCSDD/docs/api/threading/task/execute.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

837 B

ITask::Execute

virtual void Execute() = 0

任务执行逻辑(纯虚方法)。用户必须在派生类中实现此方法以定义任务的具体行为。

参数:

返回:

复杂度: 取决于具体任务实现

注意:

  • 此方法由 TaskSystem 的工作线程调用。
  • 任务执行期间如发生未捕获异常,行为未定义。

示例:

class ComputeTask : public ITask {
public:
    explicit ComputeTask(int n) : m_n(n) {}
    
    void Execute() override {
        int result = 0;
        for (int i = 0; i < m_n; ++i) {
            result += i;
        }
        printf("Result: %d\n", result);
    }
    
private:
    int m_n;
};

TaskSystem::Get().Submit(std::make_unique<ComputeTask>(100));

相关文档