[SFML 2.0] Problem z uzyciem sf::Thread
Ostatnio zmodyfikowano 2014-09-14 13:23
czosnek17 Temat założony przez niniejszego użytkownika |
[SFML 2.0] Problem z uzyciem sf::Thread » 2014-09-13 23:27:21 Próbuję utworzyć wątek za pomocą sf::Thread, ale nic nie wychodzi. Przykład: void f( int a ) { cout << "thread2 " << a << endl; }
int main() { int asd; sf::Thread thread( void( * f )( int ) ); sf::Thread thread( void( * f )( int ), int ); sf::Thread thread( void( * f )( int ), & asd ); sf::Thread thread( void( * f )( int ), int ); thread.launch(); }
Przekazywanie nazwy typu oczywiście nie ma sensu, ale się skompilowało. Funkcji launch() nie udaje się mi wywołać bez błędów. Dlaczego to nie działa - gdzie jest błąd? |
|
colorgreen19 |
» 2014-09-13 23:41:36 a tak nie możesz zrobić sf::Thread thread( & f, & asd ); ? |
|
MrPoxipol |
» 2014-09-13 23:58:06 albo std::bind()? |
|
czosnek17 Temat założony przez niniejszego użytkownika |
» 2014-09-14 13:23:37 std::bind() pomogło :) #include <functional>
void f( int a ) { cout << "thread2 " << a << endl; }
int asd = 123;
auto fa = bind( f, asd ); sf::Thread thr( fa ); thr.launch();
|
|
« 1 » |