Async 1.8.0
AsyncTaskRunner.h
Go to the documentation of this file.
1
32#ifndef ASYNC_TASK_RUNNER_INCLUDED
33#define ASYNC_TASK_RUNNER_INCLUDED
34
35
36/****************************************************************************
37 *
38 * System Includes
39 *
40 ****************************************************************************/
41
42
43
44/****************************************************************************
45 *
46 * Project Includes
47 *
48 ****************************************************************************/
49
50#include <AsyncApplication.h>
51
52
53/****************************************************************************
54 *
55 * Local Includes
56 *
57 ****************************************************************************/
58
59
60
61/****************************************************************************
62 *
63 * Forward declarations
64 *
65 ****************************************************************************/
66
67
68
69/****************************************************************************
70 *
71 * Namespace
72 *
73 ****************************************************************************/
74
75namespace Async
76{
77
78
79/****************************************************************************
80 *
81 * Forward declarations of classes inside of the declared namespace
82 *
83 ****************************************************************************/
84
85
86
87/****************************************************************************
88 *
89 * Defines & typedefs
90 *
91 ****************************************************************************/
92
93
94
95/****************************************************************************
96 *
97 * Exported Global Variables
98 *
99 ****************************************************************************/
100
101
102
103/****************************************************************************
104 *
105 * Class definitions
106 *
107 ****************************************************************************/
108
125{
126 public:
130 TaskRunner(void) {}
131
135 TaskRunner(const TaskRunner&) = delete;
136
143 {
144 cancel();
145 }
146
150 TaskRunner& operator=(const TaskRunner&) = delete;
151
152 //template <typename TaskHandler>
153 //Application::TaskId runTask(TaskHandler&& handler)
154 //{
155 // return Application::app().runTask(this,
156 // std::forward<TaskHandler>(handler));
157 //}
158
159 //template <typename Func, typename Arg1, typename... Args>
160 //Application::TaskId runTask(Func&& f, Arg1&& arg1, Args&&... args)
161 //{
162 // return Application::app().runTask(this, std::forward<Func>(f),
163 // std::forward<Arg1>(arg1), std::forward<Args>(args)...);
164 //}
165
191 template <typename TaskHandler>
192 Application::TaskId operator()(TaskHandler&& handler)
193 {
194 return Application::app().runTask(this,
195 std::forward<TaskHandler>(handler));
196 }
197
220 template <typename Func, typename Arg1, typename... Args>
221 Application::TaskId operator()(Func&& f, Arg1&& arg1, Args&&... args)
222 {
223 return Application::app().runTask(this, std::forward<Func>(f),
224 std::forward<Arg1>(arg1), std::forward<Args>(args)...);
225 }
226
230 void cancel(void)
231 {
232 Application::app().cancelTasks(this);
233 }
234}; /* class TaskRunner */
235
236
237} /* namespace */
238
239#endif /* ASYNC_TASK_RUNNER_INCLUDED */
240
241/*
242 * This file has not been truncated
243 */
The core class for writing asyncronous applications.
static Application & app(void)
Get the one and only application instance.
void runTask(sigc::slot< void > task)
Run a task from the Async main loop.
Run tasks from the Async main thread with automatic cleanup.
Application::TaskId operator()(TaskHandler &&handler)
Run a task from the Async main loop.
Application::TaskId operator()(Func &&f, Arg1 &&arg1, Args &&... args)
Run a task from the Async main loop.
TaskRunner(void)
Default constructor.
TaskRunner & operator=(const TaskRunner &)=delete
Assignment operator is deleted.
TaskRunner(const TaskRunner &)=delete
Copy constructor is deleted.
~TaskRunner(void)
Destructor.
void cancel(void)
Cancel all queued tasks for this object.
Namespace for the asynchronous programming classes.