mlrl.common.cython.multi_threading module

@author: Michael Rapp (michael.rapp.ml@gmail.com)

class mlrl.common.cython.multi_threading.ManualMultiThreadingConfig

Bases: object

Allows to configure the multi-threading behavior of a parallelizable algorithm by manually specifying the number of threads to be used.

get_num_preferred_threads() int

Returns the number of preferred threads.

Returns:

The number of preferred threads or 0, if all available CPU cores are utilized

set_num_preferred_threads(num_preferred_threads: int) ManualMultiThreadingConfig

Sets the number of preferred threads. If not enough CPU cores are available or if multi-threading support was disabled at compile-time, as many threads as possible will be used.

Parameters:

num_preferred_threads – The preferred number of threads. Must be at least 1 or 0, if all available CPU cores should be utilized

Returns:

A ManualMultiThreadingConfig that allows further configuration of the multi-threading behavior