Hi,
I am trying to use boost threads, but it seems that mutex won't work.. most
of the time it crashes..
even without starting the thread
well, I am a total nobb with threads :/ ..I managed to make the threads
work, but this was the easy part..
to copy information between threads is the big problem (thread safe)
I tried mutex, but just writing to an object with mutex locked can lead to a
crash (doesn't allways, don't know why, it seems it crashes if I copy
NodePtr and such..)
I don't know if its right what I did :
class threadContainer {// I use this to pass informations from a
Intersectaction
public:
threadContainer(){
hitObj = NullFC;
hit = false;
hitPnt = Pnt3f(0,0,0);
}
~threadContainer(){
;
}
void set(bool h, NodePtr n, Pnt3f hpnt) {
hit = h;
hitObj = n;
hitPnt = hpnt;
}
boost::recursive_mutex mutex;
NodePtr hitObj;
bool hit;
Pnt3f hitPnt;
};
and I try to write with :
if (updateIntersect and iAct_tc != 0 and iAct != 0) {//iAct_tc
is my container of type threadContainer
iAct->setLine(getLine());
if (IntersectNode != NullFC) {
iAct->apply(IntersectNode);
if (cur != 0) cur->checkPointer(iAct);
}
bool hit = iAct->didHit();
NodePtr node = NullFC;
Pnt3f hitPnt;
if (hit) {
hitPnt = iAct->getHitPoint();
node = iAct->getHitObject();
}
boost::recursive_mutex::scoped_lock
lock(iAct_tc->mutex);//lock iAct_tc mutex to write
iAct_tc->set(hit, node, hitPnt);
}
so should i use osg locks? (if yes then how?^^)
or something completly different?
or is it bullshit what I am doing? :D
Thanks, Victor
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users