Multithreading ?

Hi !

Have any one thought of multithreading when OCC was designed ?, for example can I use BRepBuilder and other classes like that in different threads without any problems (static variables and so on for example...)

And a request if possible, would it be possible to add -D_REEENTRANT to the compilation of precompiled Linux libraries in the future maybe ?

This has no impact att all on existing software (getc becomes a function call instead of an inline function and so on), this would make it possible to use Open Cascade in multithreaded application (other the the main thread).

And non multithreaded application will continue to work fine (a few clock cycles slower in putc/putc maybe....)


Robert Boehne's picture


Interesting, I don't think I have seen that before. It seems a bit strange though. I would think that gcc would have a separate flag to allow multithreading, one that would also implicitly define _REENTRANT, because I think it a bit odd to change compiler behavior with a #define. That's not to say that #defines don't change compiler behavior, but rather that they shouldn't be used to do that.
Could you point me to the gcc documentation where this is discussed?

In my "configure" script I could add a flag to support multithreading, some would want it, some would not. That's the beauty of "configure".


Mikael Aronsson's picture

Well, the gcc behavior is not changed, it's just change some stuff in the include files, that's the neat thing with glibc, the the same library is used for both single and multithreadead applications, the include file just chage what function get called, and change some inline functions to real function calls.

I have to get back to you with more info about __REENTRANT, I do not think you will find much about it in the gcc docs though, I think you have to look in the pthreads documentation (which is included with glibc2).

But I will get back to you about that.