mirror of
https://github.com/allankoechke/ThreadPool.git
synced 2026-11-30 09:59:52 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user