diff options
| author | Brendan Jurd <direvus@gmail.com> | 2021-09-27 17:17:58 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-27 09:17:58 +0200 |
| commit | e27c4424ea84160ddc957032cb65e444f7d7944a (patch) | |
| tree | 6cc74731199d03fa465aaa01dae4f7ce2964fa3b /docs/source/development/threads.rst | |
| parent | 3a827d2e041bf49e0e19800a5f666a0b1af153c3 (diff) | |
| download | PROJ-e27c4424ea84160ddc957032cb65e444f7d7944a.tar.gz PROJ-e27c4424ea84160ddc957032cb65e444f7d7944a.zip | |
DOC: Refresh Development/Quickstart and remove Development/Threads (#2863)
* DOC: Refresh Development/Quickstart and remove Development/Threads
The document Development/Threads was severely out of date, and was
focussed on contrasting the current API with an old API that was
deprecated several years ago, and removed from the current PROJ earlier
this year.
Update Development/Quickstart to give more information about the use of
threading context, as a replacement for the content that was previously
in Threads.
Also give the example code examples/pj_obs_api_mini_demo.c a cleanup
pass to make it at least internally consistent with its own code style.
The header comments of the example code are still, much like the Threads
document, fixated on comparing proj.h against proj_api.h, which is an
interesting historical curio to be sure, but probably doesn't need to
persist here. It might be worth cleaning this up further as a separate
exercise.
Fixes #2451
Diffstat (limited to 'docs/source/development/threads.rst')
| -rw-r--r-- | docs/source/development/threads.rst | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/docs/source/development/threads.rst b/docs/source/development/threads.rst deleted file mode 100644 index 674f4bd1..00000000 --- a/docs/source/development/threads.rst +++ /dev/null @@ -1,79 +0,0 @@ -.. _threads: - -================================================================================ -Threads -================================================================================ - -This page is about efforts to make PROJ thread safe. - -Key Thread Safety Issues --------------------------------------------------------------------------------- - -* the global pj_errno variable is shared between threads and makes it - essentially impossible to handle errors safely. Being addressed with the - introduction of the projCtx execution context. -* the datum shift using grid files uses globally shared lists of loaded grid - information. Access to this has been made safe in 4.7.0 with the introduction - of a PROJ mutex used to protect access to these memory structures (see - pj_mutex.c). - -projCtx --------------------------------------------------------------------------------- - -Primarily in order to avoid having pj_errno as a global variable, a "thread -context" structure has been introduced into a variation of the PROJ API for -the 4.8.0 release. The pj_init() and pj_init_plus() functions now have context -variations called pj_init_ctx() and pj_init_plus_ctx() which take a projections -context. - -The projections context can be created with pj_ctx_alloc(), and there is a -global default context used when one is not provided by the application. There -is a pj_ctx\_ set of functions to create, manipulate, query, and destroy -contexts. The contexts are also used now to handle setting debugging mode, and -to hold an error reporting function for textual error and debug messages. The -API looks like: - -:: - - projPJ pj_init_ctx( projCtx, int, char ** ); - projPJ pj_init_plus_ctx( projCtx, const char * ); - - projCtx pj_get_default_ctx(void); - projCtx pj_get_ctx( projPJ ); - void pj_set_ctx( projPJ, projCtx ); - projCtx pj_ctx_alloc(void); - void pj_ctx_free( projCtx ); - int pj_ctx_get_errno( projCtx ); - void pj_ctx_set_errno( projCtx, int ); - void pj_ctx_set_debug( projCtx, int ); - void pj_ctx_set_logger( projCtx, void (*)(void *, int, const char *) ); - void pj_ctx_set_app_data( projCtx, void * ); - void *pj_ctx_get_app_data( projCtx ); - -Multithreaded applications are now expected to create a projCtx per thread -using pj_ctx_alloc(). The context's error handlers, and app data may be -modified if desired, but at the very least each context has an internal error -value accessed with pj_ctx_get_errno() as opposed to looking at pj_errno. - -Note that pj_errno continues to exist, and it is set by pj_ctx_set_errno() (as -well as setting the context specific error number), but pj_errno still suffers -from the global shared problem between threads and should not be used by -multithreaded applications. - -Note that pj_init_ctx(), and pj_init_plus_ctx() will assign the projCtx to the -created projPJ object. Functions like pj_transform(), pj_fwd() and pj_inv() -will use the context of the projPJ for error reporting. - -src/multistresstest.c --------------------------------------------------------------------------------- - -A small multi-threaded test program has been written (src/multistresstest.c) -for testing multithreaded use of PROJ. It performs a series of reprojections -to setup a table expected results, and then it does them many times in several -threads to confirm that the results are consistent. At this time this program -is not part of the builds but it can be built on linux like: - -:: - - gcc -g multistresstest.c .libs/libproj.so -lpthread -o multistresstest - ./multistresstest |
