ANSI C Based OPC UA Client/Server SDK  1.9.0.430
Using the SDK in a Multithreaded Application

Overview

When using the SDK in a multithreaded application, some important issues have to be considered.

SDK Configuration

For being used in a multithreaded application, the SDK needs to be built with support for synchronization. Starting with version 1.4.0 this is enabled by default and can be configured using the CMake option UASTACK_USE_SYNCHRONIZATION.

See also
Configuring the SDK for details.

Using the SDK

When calling SDK functions from other threads than the SDK’s main thread (the one calling UaBase_DoCom), it is important to only call thread-safe SDK functions from these threads.

All functions that can safely be called from within other threads are marked with a note “This function is thread-safe.” in the documentation. These include:

Note
The functions marked as thread-safe are only thread-safe if the corresponding CMake option is set as described above.

All other utility functions that don’t work on structures managed by the SDK (e.g. sessions, subscriptions, monitored items) can also be safely called from another thread as long as it is ensured that the structure they are working on is not modified by another thread at the same time. These include, amongst others: