Pass task by universal reference and variadics

As suggested by daniel-j-h tasks are now taken by
universal reference and forwarded with std::forward.
Also enqueue takes a variadic argument list and binds
the arguments to the task.
This commit is contained in:
Jakob Progsch
2013-03-29 16:26:35 +01:00
parent 5d0ca72d50
commit 41355c071a
2 changed files with 9 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ int main()
for(int i = 0; i < 8; ++i) {
results.push_back(
pool.enqueue<int>([i] {
pool.enqueue([i] {
std::cout << "hello " << i << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
std::cout << "world " << i << std::endl;