hmm, I have a class which manages tracking and input via flysticks and such
the intersectAction runs in the main loop, because there is only one
"cursor"
I also made a 3D menu which needs to check for "rollover", so it needs the
information of the main intersectaction
I want to put that rollover function into a separate thread, it should
manage the rollover of the buttons, define which button is pointed at, etc..
I have two reasons for this, I want to get used to threads a little more,
and I don't want the main thread to be responsible for such things like
rollover, the different parts of my application should manage themselves
I would like to use boost threads, because they offer the possibility to run
member functions (with bind), opensg doesn't (correct me if I'm wrong)
I would really appreciate something like a working example of boost thread
with opensg if anyone has something like that
thx,
Victor
PS:
I wrote :
> 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);
> }
this was the part in the main thread, the problem was the mutex, I
believe it messed up the aspects or something, I'm not sure
------------------------------------------------------------------------------
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