RecAPI
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Modules Pages
Multi-threading in RecAPI

RecAPI of the OmniPage Capture SDK is a thread-safe API starting from version 16 (supported on: Windows, Linux). This means that the API functions can be called from different threads at the same time.

If each thread uses a Settings Collection separated only for that thread, the thread-safeness is completely true. The same Settings Collection may be also used in different threads at the same time. However, when a value in a Settings Collection is changed in one thread, this new value appears in all the threads using the same Settings Collection. In this case, it is difficult to determine when the functions in the other threads notice this modification.

If this latter case poses a problem for the integrating application, there are two solutions:

  • each thread uses its own Settings Collection dedicated only to that thread or
  • the integrating application synchronizes the setting modifications performed in Settings Collections assigned to more than one thread.

The expression thread-safe does not mean all the CSDK elements can work simultaneously.

  • Some parts of the CSDK (e.g. output converting) can run only one instance at a time, i.e. if they are called simultaneously, one waits for the other,
  • There are some operations that perform multi-threaded processing within themselves (e.g. One Step Functions Module). Calling such operations simultaneously cannot achieve higher performance.
  • There are some operations that must be called one after the other sequentially, because one waits for output from another. Of course, in such a case there is no point in calling them at the same time. E.g. the preprocessing of a page must precede the recognition of that page. Of course, these operations can be called simultaneously for different pages.

Both the Engine init and quit should be in the main thread. Otherwise, the application developer must ensure that the Engine is active until the closing RecAPI call of the last thread returns.

Special notes on Linux

Using fork together with threads can cause issues and requires precautions. In general, forking should precede the creation of new threads. Since CSDK initialization may create threads, fork should take place prior to the initialization.

See also
Settings Collections - General Operations Module
Settings Collections - Settings Manager Module