Thanx Robert!
I works fine
Here is my class if it will be useful for someone.
lass UpdateMissileOperation : public osg::Operation
{
public:
UpdateMissileOperation():
Operation("UpdateMissileOperation", true)
{
}
virtual void operator () (osg::Object* callingObject)
{
osgViewer::Viewer* viewer =
dynamic_cast<osgViewer::Viewer*>(callingObject);
double t;
if (viewer)
t = viewer->getFrameStamp()->getSimulationTime();
_dt=t-_time;
if ((_dt>=0.02))
{
//printf("%f\n",_dt);
update();
_time=t;
}
else
{
OpenThreads::Thread::YieldCurrentThread();
}
}
void update()
{
//printf("%f\n",_time);
}
virtual void release()
{
}
bool _load;
bool _valid1;
float _time;
float _dt;
};
From: [email protected]
[mailto:[email protected]] On Behalf Of Roman
Grigoriev
Sent: Friday, March 20, 2009 3:42 PM
To: 'OpenSceneGraph Users'
Subject: Re: [osg-users] osg::Operation lags
Thanx Robert!
Working with threads a little bit unfamiliar to me.
Could you please point me to some examples how to use YieldCurrentThread()
Thanx in advance
Bye
From: [email protected]
[mailto:[email protected]] On Behalf Of Robert
Osfield
Sent: Friday, March 20, 2009 1:44 PM
To: OpenSceneGraph Users
Subject: Re: [osg-users] osg::Operation lags
HI Roman,
2009/3/20 Roman Grigoriev <[email protected]>
Hi Robert!
As you've seen in my operation thread I simply write to stdout simple
message: "update" and nothing more.
But framerate lags unpredictable.
Maybe there is good example or readme how to use operationthread
Thanx in advance
I have never seen problems like yours when using OperationThread/Operatons,
but on a second review I see that your OpenThread never sleeps, it just
churns away as effectively a spin lock on the CPU. If your machine doesn't
have sufficient cores to handle a thead using 100% of the CPU core then
you'll get frame stalls like you have.
Try sticking a OpenThreads::Thread::YieldCurrentThread() into your
operation.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org