SFML community forums

Help => System => Topic started by: Richy19 on December 10, 2011, 06:04:15 pm

Title: Threads inside classes
Post by: Richy19 on December 10, 2011, 06:04:15 pm
Im trying to integrate a thread into the image loading class, but im getting errors
using this code

Code: [Select]


class TextureResourceManager
{void LoadFiles();
    sf::Thread imgThread;
};

TextureResourceManager::TextureResourceManager():
imgThread(&TextureResourceManager::LoadFiles)
{

}


gives me:
Quote

||=== Agame, Debug ===|
/usr/local/include/SFML/System/Thread.inl||In member function ‘void sf::priv::ThreadFunctor<T>::Run() [with T = void (TextureResourceManager::*)()]’:|
/home/richy/codeblocks/Agame/src/TextureResourceManager.cpp:73|1|instantiated from here|
/usr/local/include/SFML/System/Thread.inl|39|error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘((sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>*)this)->sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>::myFunctor (...)’, e.g. ‘(... ->* ((sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>*)this)->sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>::myFunctor) (...)’|
||=== Build finished: 1 errors, 0 warnings ===|

Title: Threads inside classes
Post by: Groogy on December 10, 2011, 09:06:22 pm
you also have to supply the this pointer to the thread object.
Title: Threads inside classes
Post by: Laurent on December 10, 2011, 11:51:41 pm
Read the doc!! :evil:
Title: Threads inside classes
Post by: OniLinkPlus on December 13, 2011, 01:02:03 am
You broke Laurent. Good job.
Title: Threads inside classes
Post by: Laurent on December 13, 2011, 07:45:55 am
Quote
You broke Laurent. Good job

You fixed me, thanks :lol: