MeVisLab Toolbox Reference
Multi-Threading Overview

Reentrancy and Thread-safety

This documents the state of the thread support in the ML and the toolbox libraries.

Within the ML and its libraries, the following definitions are used:

Reentrancy

A reentrant function can be called simultaneously by multiple threads provided that each invocation of the function references unique data. A class is said to be reentrant if each and every one of its functions can be called simultaneously by multiple threads on different instances of the class

Thread-Safety

A thread-safe function can be called simultaneously by multiple threads when each invocation references shared data. All access to the shared data is serialized. A class is said to be thread-safe if the functions can be called by different threads on the same instance.

Thread-safe Classes and Functions in the ML

The following classes/functions are reentrant:

The following classes/functions are thread-safe:

  • ML_PRINT_ERROR, ML_PRINT_WARNING etc. may be used in any thread (as long as the error output handler that is registered with the ML supports this)
  • Thread-safe Classes and Functions

The following classes/functions are not thread-safe:

  • ML_TRACE_IN* macros, see TraceBuffer for details (although it is crash-safe to use them from other threads)
  • The Host, which may only be accessed from the main thread, unless stated differently in individual methods
  • The Field class and its notification mechanism, which may be used from the main thread only
  • The Module class, which may be used from the main thread only, with the exception of some methods that are documented to be thread-safe.
  • Non-thread-safe Classes and Functions