Function rayon::initialize [] [src]

pub fn initialize(config: Configuration) -> Result<(), InitError>

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 simply check that the global thread pool already has the configuration you requested, rather than making changes.

An Ok result indicates that the thread pool is running with the given configuration. Otherwise, a suitable error is returned.