Function rayon::initialize [] [src]

pub fn initialize(config: Configuration) -> Result<(), Box<Error + 'static>>

Initializes the global thread pool. This initialization is optional. If you do not call this function, the thread pool will be automatically initialized with the default configuration. In fact, calling initialize is not recommended, except for in two scenarios:

  • You wish to change the default configuration.
  • You are running a benchmark, in which case initializing may yield slightly more consistent results, since the worker threads will already be ready to go even in the first iteration. But this cost is minimal.

Initialization of the global thread pool happens exactly once. Once started, the configuration cannot be changed. Therefore, if you call initialize a second time, it will return an error. An Ok result indicates that this is the first initialization of the thread pool.