[GRASS-dev] Using GRASS in long running and multithreaded applications Was: Re: The tomcat shut down ...

Glynn Clements glynn at gclements.plus.com
Fri Oct 2 23:35:51 EDT 2009


Soeren Gebbert wrote:

> >> Example which works for me in my test code:
> >>
> >> /*Thread local and setjmp() exception support*/
> >> #include <setjmp.h>
> >> #ifdef WIN32
> >> #define Thread   __declspec( thread )
> >> #else
> >> #define Thread   __thread
> >> #endif
> >
> > The __thread qualifier is a gcc extension.
> 
> Yes, wikipedia says it works for:
> Sun Studio C/C++, IBM XL C/C++, GNU C and Intel C/C++ (Linux systems)
> 
> Using the pthreads implementation will be a better solution?

Any thread-local state needs to be conditionalised upon the actual
threading mechanism used, with a fall-back to a single instance (i.e. 
a simple variable).

> >> Is this approach ok or to simple or just naive? :)
> >
> > It's too invasive. The longjmp() should go into an application-defined
> > error handler, rather than the GRASS libraries.
> 
> Ok. The error handler looks like that for now:

[snip]

Yep; that's the general idea.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list