@@ -102,9 +102,16 @@ class PeripheryTaskScheduler {
102102 // / @brief Remove task, used in scenarios where it is not necessary to wait for tasks to complete before exiting.
103103 // / @param task_id task id
104104 // / @return on success, return true. on error, return false
105- // / @note This interface can only be called once with the same ID.
105+ // / @note This interface can only be called once with the same ID. After call it, the task_id can't be used again
106106 bool RemoveTask (std::uint64_t task_id);
107107
108+ // / @brief Detach task, after calling this interface, the lifecycle of this task will be managed by the scheduler,
109+ // users no longer need to concern themselves with the release of the task.
110+ // / @param task_id task id
111+ // / @return on success return true, otherwise return false
112+ // / @note the task_id can't be used again after calling this interface
113+ bool DetachTask (std::uint64_t task_id);
114+
108115 // / @brief Same as 'SubmitTask', but is used only internally by the framework.
109116 std::uint64_t SubmitInnerTask (Function<void ()>&& task, const std::string& name = "");
110117
@@ -119,10 +126,13 @@ class PeripheryTaskScheduler {
119126 // / @brief Same as 'RemoveTask', but is used only internally by the framework.
120127 bool RemoveInnerTask (std::uint64_t task_id);
121128
122- // / @brief Same as 'Stoptask', but is used only internally by the framework.
129+ // / @brief Same as 'DetachTask', but is used only internally by the framework.
130+ bool DetachInnerTask (std::uint64_t task_id);
131+
132+ // / @brief Same as 'StopTask', but is used only internally by the framework.
123133 bool StopInnerTask (std::uint64_t task_id);
124134
125- // / @brief Same as 'Jointask ', but is used only internally by the framework.
135+ // / @brief Same as 'JoinTask ', but is used only internally by the framework.
126136 bool JoinInnerTask (std::uint64_t task_id);
127137
128138 // / @brief Used to destroy resources accessed by scheduled tasks after all scheduled task execution threads have
@@ -158,6 +168,7 @@ class PeripheryTaskScheduler {
158168 bool StopTaskImpl (std::uint64_t task_id);
159169 bool JoinTaskImpl (std::uint64_t task_id);
160170 bool RemoveTaskImpl (std::uint64_t task_id);
171+ bool DetachTaskImpl (uint64_t task_id);
161172
162173 void Init (size_t thread_num);
163174 void Start ();
0 commit comments