1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
void AIShell::vertCombos (int &my_combo, int &opp_combo, int &score, int ** gameState){
for (int i = 0; i < numCols; i++){
my_combo = 0;
opp_combo = 0;
for (int j = 0; j < numRows; j++){
if (gameState[i][j] == NO_PIECE){
++my_combo;
++opp_combo;
}
else if (gameState[i][j] == AI_PIECE){
++my_combo;
opp_combo = 0;
}
else if (gameState[i][j] == HUMAN_PIECE){
my_combo = 0;
++opp_combo;
}
if (my_combo == k){
++score;
my_combo = k-1;
}
if (opp_combo == k){
--score;
opp_combo = k-1;
}
}
}
pthread_exit(NULL);
}
| |
So Im trying to do multi threading. The function above is the thread that I want to run from my main function and in my main function Im doing:
std::thread t1(&AIShell::vertCombos, my_combo, opp_combo, score, gameState);
I end up getting these errors:
^
In file included from AIShell.cpp:1:0:
AIShell.h:39:14: error: candidate is: void AIShell::vertCombos(int&, int&, int&, int**&)
void vertCombos (int &my_combo, int &opp_combo, int &score, int ** &gameState);
^
In file included from /usr/include/c++/4.8.2/thread:39:0,
from AIShell.h:7,
from AIShell.cpp:1:
/usr/include/c++/4.8.2/functional: In instantiation of ‘struct std::_Bind_simple<std::_Mem_fn<void (AIShell::*)(int&, int&, int&, int**&)>(int, int, int, int***)>’:
/usr/include/c++/4.8.2/thread:137:47: required from ‘std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (AIShell::*)(int&, int&, int&, int**&); _Args = {int&, int&, int&, int***}]’
AIShell.cpp:222:84: required from here
/usr/include/c++/4.8.2/functional:1697:61: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (AIShell::*)(int&, int&, int&, int**&)>(int, int, int, int***)>’
typedef typename result_of<_Callable(_Args...)>::type result_type;
^
/usr/include/c++/4.8.2/functional:1727:9: error: no type named ‘type’ in ‘class std::result_of<std::_Mem_fn<void (AIShell::*)(int&, int&, int&, int**&)>(int, int, int, int***)>’
_M_invoke(_Index_tuple<_Indices...>)