#include <ctpl.h>
#include <iostream>
#include <string>
Go to the source code of this file.
|
void | first (int id) |
|
void | aga (int id, int par) |
|
void | mmm (int id, const std::string &s) |
|
void | ugu (int id, Third &t) |
|
int | main (int argc, char **argv) |
|
◆ aga()
void aga |
( |
int |
id, |
|
|
int |
par |
|
) |
| |
Definition at line 11 of file example.cpp.
12 std::cout <<
"hello from " <<
id <<
", function with parameter " << par <<
'\n';
◆ first()
Definition at line 7 of file example.cpp.
8 std::cout <<
"hello from " <<
id <<
", function\n";
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 32 of file example.cpp.
35 std::future<void> qw = p.push(std::ref(
first));
41 Second(
const std::string & s) { std::cout <<
"Second ctor\n"; this->s = s; }
42 Second(Second &&
c) { std::cout <<
"Second move ctor\n"; s = std::move(
c.s); }
43 Second(
const Second &
c) { std::cout <<
"Second copy ctor\n"; this->s = c.s; };
44 ~Second() { std::cout <<
"Second dtor\n"; }
45 void operator()(
int id)
const {
46 std::cout <<
"hello from " <<
id <<
' ' << this->s <<
'\n';
50 } second(
", functor");
52 p.push(std::ref(second));
53 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
54 p.push(const_cast<const Second &>(second));
55 p.push(std::move(second));
57 p.push(Second(
", functor"));
62 p.push(
ugu, std::ref(t));
64 p.push(
ugu, std::move(t));
71 std::string s =
", lambda";
73 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
74 std::cout <<
"hello from " <<
id <<
' ' << s <<
'\n';
78 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
79 std::cout <<
"hello from " <<
id <<
' ' << s <<
'\n';
82 p.push(
mmm,
"worked");
86 std::cout <<
"poped function from the pool ";
93 std::string s2 =
"result";
94 auto f1 = p.push([s2](
int){
99 std::cout <<
"returned " << f1.get() <<
'\n';
101 auto f2 = p.push([](
int){
102 throw std::exception();
109 catch (std::exception & e) {
110 std::cout <<
"caught exception\n";
114 auto & th = p.get_thread(0);
void mmm(int id, const std::string &s)
void aga(int id, int par)
void ugu(int id, Third &t)
◆ mmm()
void mmm |
( |
int |
id, |
|
|
const std::string & |
s |
|
) |
| |
Definition at line 23 of file example.cpp.
24 std::cout <<
"mmm function " <<
id <<
' ' << s <<
'\n';
◆ ugu()
void ugu |
( |
int |
id, |
|
|
Third & |
t |
|
) |
| |
Definition at line 27 of file example.cpp.
28 std::this_thread::sleep_for(std::chrono::milliseconds(2000));
29 std::cout <<
"hello from " <<
id <<
", function with parameter Third " << t.
v <<
'\n';