Skip to content

Threadpool: Always call initialize/finalizeThread

Simon Spannagel requested to merge threadpool_singlethreaded into master

Up till now, the initializeThread and finalizeThread methods defined by modules were not called at all when running in single-threaded mode. While this - in principle - is okay because no thread-specific initialization needs to happen, it leads to a rather ugly patterns of

void initialize() {
    if(!multithreadingEnabled()) {
        initialize_some_things();
    }
}

void initializeThreads() {
    if(multithreadingEnabled()) {
        initialize_some_things();
    }
}

In order to overcome this, I would suggest to always call the respective methods, in case of single-threading we call it on the main thread (and of course just once).

Affected modules are adapted, documentation updated.

Merge request reports