3 Copyright (C) 2023-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef GDBSUPPORT_TASK_GROUP_H
21 #define GDBSUPPORT_TASK_GROUP_H
28 /* A task group is a collection of tasks. Each task in the group is
29 submitted to the thread pool. When all the tasks in the group have
30 finished, a final action is run. */
36 explicit task_group (std::function
<void ()> &&done
);
37 DISABLE_COPY_AND_ASSIGN (task_group
);
39 /* Add a task to the task group. All tasks must be added before the
40 group is started. Note that a task may not throw an
42 void add_task (std::function
<void ()> &&task
);
44 /* Start this task group. A task group may only be started once.
45 This will submit all the tasks to the global thread pool. */
52 /* A task group is just a facade around an impl. This is done
53 because the impl object must live as long as its longest-lived
54 task, so it is heap-allocated and destroyed when the last task
56 std::shared_ptr
<impl
> m_task
;
61 #endif /* GDBSUPPORT_TASK_GROUP_H */