libtasks Documentation  1.6
exec.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2014 ADTECH GmbH
3  * Licensed under MIT (https://github.com/adtechlabs/libtasks/blob/master/COPYING)
4  *
5  * Author: Andreas Pohl
6  */
7 
8 #include <tasks/exec.h>
9 #include <tasks/exec_task.h>
10 #include <tasks/dispatcher.h>
11 
12 namespace tasks {
13 
14 void exec(exec_task::func_t f) { dispatcher::instance()->add_task(new exec_task(f)); }
15 
17  exec_task* t = new exec_task(f);
18  t->on_finish(ff);
19  dispatcher::instance()->add_task(t);
20 }
21 
22 } // tasks
std::function< void()> finish_func_void_t
Definition: task.h:22
static std::shared_ptr< dispatcher > instance()
Definition: dispatcher.h:75
void on_finish(finish_func_worker_t f)
Definition: task.h:56
void exec(exec_task::func_t f)
Execute code in a separate executor thread.
Definition: exec.cpp:14
std::function< void()> func_t
Definition: exec_task.h:20