Opened 11 years ago
Closed 9 years ago
#663 closed enhancement (fixed)
Extend C api to make thread-safe message handling easier
Reported by: | pepijnve | Owned by: | strk |
---|---|---|---|
Priority: | major | Milestone: | 3.5.0 |
Component: | C API | Version: | 3.4.2 |
Severity: | Feature Request | Keywords: | |
Cc: | thread |
Description
The current C api allows you to register notice and error handlers on a GEOS context using callback functions. This mechanism does not provide a means to associate context specific data with the callback making it difficult to capture the messages and process them in a thread safe way.
An example usage where this is needed can be seen in https://bitbucket.org/luciad/libgpkg/src/185e4a928c90b797401f8d3132c7bac97bd3b41a/gpkg/geom_func_geos.c?at=default The code in question stores the error message and passes it on to sqlite as an error message to provide informative errors to the user. In order to make this thread safe use of thread-local storage (or some other synchronization mechanism) is required.
I would like to propose extending the current API with a new message handler interface that provides a means to associate user data (as void*) with a registered callback function. In the example that I referred to, this would allow you to tie the sqlite user data to the callback which obviates the need for additional synchronization mechanisms.
I've coded a proposed solution for this ticket which can be found at https://github.com/libgeos/libgeos/pull/26.
Change History (2)
comment:1 by , 9 years ago
Milestone: | GEOS Future → 3.5.0 |
---|
comment:2 by , 9 years ago
Cc: | added |
---|---|
Resolution: | → fixed |
Status: | new → closed |
r4060 merges the patch. Thank yo !
I think this would be better done for 3.5.0. Especially since a patch exists for it.