Documentation Center

Multi-Threaded Approach

Many of the Contenta Web views consist of multiple panes which means that multiple threads can be competing for access to the Contenta Server process, the Portal.

The Operating System manages these threads and, to optimize performance, swaps the threads as it determines appropriate. This can lead to unexpected results when one thread is swapped out and its communication with the Portal is interrupted. Note:

  • If a thread is swapped out and second thread is swapped in, the second thread may make further Portal calls which could change the focus from the object that had been selected by the first thread. When the first thread is then swapped back in, it may no longer be focused on the object that it had previously selected
  • If the first thread is swapped out after a Portal call is made but before the Portal has returned the results, then a second thread is swapped in that performs other Portal calls, the first thread gets indeterminate results from its original Portal call. This can, for example, lead to the Configuration ID being appended to the object ID path in a data object.

To overcome this, a synchronization object was introduced that ensures that the object that was last selected is re-selected before the next command is issued to the Portal. This prevents any swapping from occurring while the Portal communication takes place. In addition to this, setTransactionOn and setTransactionOff commands were added to the Portal. While this is set to on, the OS is prevented from swapping

Both of these approaches provide a safe method of communicating with the Portal in a multi-threaded environment, but they have a performance impact since the OS is prevented from carrying out performance optimization tasks, such as swapping, while these commands are executed.

To minimize impact on performance, these functions should only be used when necessary. SDL has minimized the use of these functions in the development of the core Contenta Web product and the associated tools that are delivered with the product.