Hi all,
I am trying to implement a threaded version of a class that controls points (particles) on screen.
class threadedParticleSystem : public ofThread
{
public:
threadedParticleSystem(){}
threadedParticleSystem( int _num, ofVec2f _origin, float _width, float _height );
~threadedParticleSystem();
//thread functions
void start(){ startThread(true, false); } // blocking, verbose
void stop(){ stopThread(); }
void threadedFunction()
{
while(isThreadRunning() !=0)
{
if ( lock() )
{
updateThread();
unlock();
}
}
}
//not necessarily threaded functions
void addParticle();
void applyForce(ofVec2f f);
//shared variables
vector <simpleParticle> particles;
private:
void updateThread();
};
There are a number of questions that I have here:
- the “threadedFunction()” is a callback function that the poco thread calls?
- the member functions addParticle() and applyForce() are run in the thread? or will they be called from the main thread?
I try to instantiate the object above in another class
.h:
threadedParticleSystem ps0;
.cpp:
(in constructor)
ps0 = threadedParticleSystem(0, ofVec2f(400,PROJECTOR_HEIGHT+10), 100, 0) );
if I try to compile this I get the following weird error
In file included from ../../../libs/openFrameworks/types/ofTypes.h:69:0,
from ../../../libs/openFrameworks/utils/ofLog.h:5,
from ../../../libs/openFrameworks/ofMain.h:7,
from src/scenes/sceneGeiser/sceneGeiser.h:2,
from src/scenes/sceneGeiser/sceneGeiser.cpp:1:
../../../libs/poco/include/Poco/Mutex.h: In member function ‘ofThread& ofThread::operator=(const ofThread&)’:
../../../libs/poco/include/Poco/Mutex.h:171:13: error: ‘Poco::FastMutex& Poco::FastMutex::operator=(const Poco::FastMutex&)’ is private
FastMutex& operator = (const FastMutex&);
I have not idea what I do wrong and the compile error ended up being thrown at FastMutex assignment operator.
thank you for your help