progschj / ThreadPool

A simple C++11 Thread Pool implementation
zlib License
7.64k stars 2.21k forks source link

How can We USE A FUNCTION INSIDE YOUR CODE?? #29

Closed hanito closed 8 years ago

hanito commented 8 years ago

How can we add a function inside your code. IT's totally unclear

wilx commented 8 years ago

What do you mean? The example.cpp shows hot to use the thread pool.

progschj commented 8 years ago

This should do it i think:

int foo(float x) { return x; }
//...
future<int> result = pool.enqueue(foo, 3.14f); 
hanito commented 8 years ago

yes Prog I coded it before. For a class I should do the following: IF i have a function bar in a class int foo::bar(float x) { return x; } //... future result = pool.enqueue(&foo::bar, this, 3.14f);