-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functions to interrupt processing in a specific thread/context #803
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,8 +296,8 @@ typedef int (*GEOSTransformXYCallback)( | |
/* ========== Interruption ========== */ | ||
|
||
/** | ||
* Callback function for use in interruption. The callback will be invoked _before_ checking for | ||
* interruption, so can be used to request it. | ||
* Callback function for use in interruption. The callback will be invoked at each | ||
* possible interruption point and can be used to request interruption. | ||
* | ||
* \see GEOS_interruptRegisterCallback | ||
* \see GEOS_interruptRequest | ||
|
@@ -306,19 +306,56 @@ typedef int (*GEOSTransformXYCallback)( | |
typedef void (GEOSInterruptCallback)(void); | ||
|
||
/** | ||
* Register a function to be called when processing is interrupted. | ||
* Callback function for use in interruption. The callback will be invoked at each | ||
* possible interruption point and can be used to request interruption. | ||
* | ||
* \see GEOS_interruptRegisterThreadCallback | ||
* \see GEOS_interruptThread | ||
*/ | ||
typedef void (GEOSInterruptThreadCallback)(void*); | ||
|
||
/** | ||
* Register a function to be called when a possible interruption point is reached | ||
* on any thread. The function may be used to request interruption. | ||
* | ||
* \param cb Callback function to invoke | ||
* \return the previously configured callback | ||
* \return the previously registered callback, or NULL | ||
* \see GEOSInterruptCallback | ||
* \see GEOSContext_setInterruptCallback_r | ||
*/ | ||
extern GEOSInterruptCallback GEOS_DLL *GEOS_interruptRegisterCallback( | ||
GEOSInterruptCallback* cb); | ||
|
||
/** | ||
* Request safe interruption of operations | ||
* Register a function to be called when a possible interruption point is reached | ||
* in code executed in the specified context. The function can interrupt the | ||
* thread if desired by calling GEOS_interruptThread. | ||
* | ||
* \param extHandle the context returned by \ref GEOS_init_r. | ||
* \param cb Callback function to invoke | ||
* \param userData optional data to be pe provided as argument to callback | ||
* \return the previously registered callback, or NULL | ||
* \see GEOSInterruptThreadCallback | ||
*/ | ||
Comment on lines
+330
to
+339
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we say that you should not start other GEOS operations inside of the callback? I ccould imagine folks wanting to make the decision based on the result of some geos operation, but that would risk clobbering the thread_local state used to store the interrupt state. |
||
extern GEOSInterruptThreadCallback GEOS_DLL *GEOSContext_setInterruptCallback_r( | ||
GEOSContextHandle_t extHandle, | ||
GEOSInterruptThreadCallback* cb, | ||
void* userData); | ||
Comment on lines
+340
to
+343
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbaston what do you think about making this callback return a value that indicates whether an interrupt is desired and eliminating |
||
|
||
/** | ||
* Request safe interruption of operations. The next thread to check for an | ||
* interrupt will be interrupted. To request interruption of a specific thread, | ||
* instead call GEOS_interruptThread() from a callback executed by that thread. | ||
*/ | ||
extern void GEOS_DLL GEOS_interruptRequest(void); | ||
|
||
/** | ||
* Request safe interruption of operations in the current thread. This function | ||
* should be called from a callback registered by GEOS_interruptRegisterThreadCallback() | ||
* or GEOS_interruptRegisterCallback(). | ||
*/ | ||
extern void GEOS_DLL GEOS_interruptThread(void); | ||
|
||
/** | ||
* Cancel a pending interruption request | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid the word thread in these new APIs and associated documentation. Maybe this one could be named
GEOSContextInterruptCallback
and similar for other new symbols.