Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3509 Members - Latest Member: lioneltenel

27. May 2012, 03:48:47 am
Xith3D CommunityXith3D InternalsDeveloper discussion (Moderators: Marvin Fröhlich, 'n ddrylliog)openmali thread safety
Pages: [1]
Print
Author Topic: openmali thread safety  (Read 1036 times)
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« on: 06. May 2008, 10:55:20 am »

I am currently correcting the ray-triangle intersection code in openmali and noticed the following code block:

Code:
    /*
     * static final fields that are reused for computations, so the
     * computations don't tax the garbage collector
     */
    private static final Point3f  tmpPnt  = new Point3f();
    private static final Matrix3f tmpMat  = new Matrix3f();
    private static final Vector3f tmpVec1 = new Vector3f();
    private static final Vector3f tmpVec2 = new Vector3f();
    private static final Vector3f tmpVec3 = new Vector3f();
    private static final Vector3f tmpVec4 = new Vector3f();
    private static final Vector3f tmpVec5 = new Vector3f();
    private static final Vector3f tmpVec6 = new Vector3f();

This is very problematic to me, because it makes the whole Triangle class non-thread-safe - regardless of different instances. While I consider it ok to have a non-thread-safe scene graph, I consider it a no go to have a non-thread-safe math library, since it prevents off render thread computations.

I will change the Triangle class to object pooling.

What do you think? Do you know of other such use cases in openmali?


Logged

Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 06. May 2008, 11:07:38 am »

While I consider it ok to have a non-thread-safe scene graph, I consider it a no go to have a non-thread-safe math library, since it prevents off render thread computations.

I will change the Triangle class to object pooling.

What do you think?

Go ahead and change that. Should be no problem.

Do you know of other such use cases in openmali?

vecmath2 is designed to produce no garbage collection at the (possible) cost of thread-safety. So I guess, vecmath2 is not thread safe as a whole. Though there shouldn't be too many cases, where static helper instances are used like above.

Marvin
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #2 on: 06. May 2008, 11:21:49 am »

As long as only the instances aren't thread safe, I think it is ok, when documented.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic