SFML community forums
General => Feature requests => Topic started by: Regen on August 01, 2008, 11:59:16 am
-
I think it would be nice to add a function to the sf::thread class.
A IsRunning() thingy.
I know the tutorial suggests to have a globel bool called ThreadRunning, but if you have alot of threads i could be messy, i dont like to use globals at all :?
-
Well, you're using a derived class for your own threads right ? (yes you do, using callbacks is not clean C++ and is meant only for compatibility with other languages).
So you can just add this feature to your class.
class MyThread : public sf::Thread
{
public :
MyThread() : IsRunning(false) {}
bool IsRunning() const {return IsRunning;}
private :
virtual void Run()
{
IsRunning = true;
// ...
IsRunning = false;
}
bool IsRunning;
};