Threading in cppTango

What is the correct way of creating threads for background processes in a device server created with cppTango? Should omni_threads be implemented or can std::thread be used as in any C++ standalone project? Using C++17.

Using std::thread can work, but if you wish to interact with a Tango device from this thread then you need to allocate an omni_thread ID for you thread by allocating an omni_thread::ensure_self object from your thread.

This object should exist for the duration of your thread so that thread has a stable ID, so, the easiest thing is allocate it on the stack at the start of your thread.

1 Like