|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Abstract base class for dispatching tasks to the thread that owns DataStorage. More...
#include <mitkStorageThreadDispatcherBase.h>


Public Member Functions | |
| mitkClassMacroItkParent (StorageThreadDispatcherBase, itk::Object) | |
| void | Execute (std::function< void()> task) |
| Execute a task on the storage-owning thread, blocking until completion. More... | |
| virtual bool | IsDispatchThread () const =0 |
| Check if the current thread is the dispatch target thread. More... | |
| virtual void | Post (std::function< void()> task)=0 |
| Post a task to run on the storage-owning thread, returning immediately. More... | |
| template<typename R > | |
| R | ExecuteWithResult (std::function< R()> task) |
| Convenience template for tasks that return a value. More... | |
Protected Member Functions | |
| virtual void | ExecuteDispatched (std::function< void()> task)=0 |
| Execute a task on the storage-owning thread, blocking until completion. More... | |
| StorageThreadDispatcherBase ()=default | |
| ~StorageThreadDispatcherBase () override=default | |
Abstract base class for dispatching tasks to the thread that owns DataStorage.
Implementations provide thread-marshaling to ensure DataStorage operations (which trigger synchronous observer events) execute on the correct thread. (e.g. the Qt implementation dispatches to the GUI main thread.)
In headless/test scenarios, no dispatcher is needed - tasks execute directly.
Definition at line 32 of file mitkStorageThreadDispatcherBase.h.
|
protecteddefault |
|
overrideprotecteddefault |
|
inline |
Execute a task on the storage-owning thread, blocking until completion.
Checks thread affinity automatically to avoid deadlocks (e.g., Qt::BlockingQueuedConnection deadlocks if called from the target thread). If on the dispatch thread, executes the task directly.
Definition at line 46 of file mitkStorageThreadDispatcherBase.h.
|
protectedpure virtual |
Execute a task on the storage-owning thread, blocking until completion.
Must be implemented in derived classes.
| [in] | task | the task to execute on the dispatch thread. |
|
inline |
Convenience template for tasks that return a value.
Blocks until the task completes and returns the result.
Definition at line 93 of file mitkStorageThreadDispatcherBase.h.
|
pure virtual |
Check if the current thread is the dispatch target thread.
Callers can check this before Execute(), but Execute() does it automatically to avoid deadlocks (e.g., Qt::BlockingQueuedConnection deadlocks if called from the target thread).
| mitk::StorageThreadDispatcherBase::mitkClassMacroItkParent | ( | StorageThreadDispatcherBase | , |
| itk::Object | |||
| ) |
|
pure virtual |
Post a task to run on the storage-owning thread, returning immediately.
Unlike Execute(), Post() never runs the task inline: it always defers to a later turn of the dispatch thread's event loop, even when called from the dispatch thread itself. Callers rely on that deferral – e.g. to escape a context (such as the platform loader lock held during library/plugin load) in which running the task synchronously would deadlock.
The task's result, if any, is discarded (fire-and-forget). Ordering relative to other posted tasks follows the dispatch thread's own queue semantics.