mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
Add methods to retrieve current thread affinity and push contexts
to another thread With suitable assert in place to ensure that pushes are only made when current thread == existing thread affinity
This commit is contained in:
parent
1dce459610
commit
6c6f646291
@ -214,6 +214,21 @@ Destination project
|
|||||||
and no errors will occur if feedback is deleted before the context.
|
and no errors will occur if feedback is deleted before the context.
|
||||||
Ownership of ``feedback`` is not transferred.
|
Ownership of ``feedback`` is not transferred.
|
||||||
.. seealso:: setFeedback()
|
.. seealso:: setFeedback()
|
||||||
|
%End
|
||||||
|
|
||||||
|
QThread *thread();
|
||||||
|
%Docstring
|
||||||
|
Returns the thread in which the context lives.
|
||||||
|
.. seealso:: pushToThread()
|
||||||
|
:rtype: QThread
|
||||||
|
%End
|
||||||
|
|
||||||
|
void pushToThread( QThread *thread );
|
||||||
|
%Docstring
|
||||||
|
Pushes the thread affinity for the context (including all layers contained in the temporaryLayerStore()) into
|
||||||
|
another ``thread``. This method is only safe to call when the current thread matches the existing thread
|
||||||
|
affinity for the context (see thread()).
|
||||||
|
.. seealso:: thread()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -310,6 +310,24 @@ class CORE_EXPORT QgsProcessingContext
|
|||||||
*/
|
*/
|
||||||
void setFeedback( QgsProcessingFeedback *feedback ) { mFeedback = feedback; }
|
void setFeedback( QgsProcessingFeedback *feedback ) { mFeedback = feedback; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the thread in which the context lives.
|
||||||
|
* \see pushToThread()
|
||||||
|
*/
|
||||||
|
QThread *thread() { return tempLayerStore.thread(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes the thread affinity for the context (including all layers contained in the temporaryLayerStore()) into
|
||||||
|
* another \a thread. This method is only safe to call when the current thread matches the existing thread
|
||||||
|
* affinity for the context (see thread()).
|
||||||
|
* \see thread()
|
||||||
|
*/
|
||||||
|
void pushToThread( QThread *thread )
|
||||||
|
{
|
||||||
|
Q_ASSERTX( QThread::currentThread() == thread(), "QgsProcessingContext::pushToThread", "Cannot push context to another thread unless the current thread matches the existing context thread affinity" );
|
||||||
|
tempLayerStore.moveToThread( thread );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QgsProcessingContext::Flags mFlags = 0;
|
QgsProcessingContext::Flags mFlags = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user