Timers and callbacks are essential tools for programming, especially for control systems that require precise and reliable timing. Both core Java and third-party libraries offer various ways to create and use timers, but they do not cover all the scenarios that control systems face. Therefore, KOS provides a set of specialized callback classes that handle common and complex timer-based problems.
The term callback is used to describe these classes because they offer more than just simple timer functionality. They also provide guarantees about the execution of the callback method, such as ensuring that no callback is ever invoked concurrently, and that they are performed in order. Even if a breakpoint occurs during a callback, and more events trigger the same timer, the pending callback events are queued and executed in a sequential order.
Timers and callbacks can introduce subtle bugs and race conditions in multi-threaded applications, which can compromise the performance and safety of control systems. The KOS callback classes are designed to prevent these issues by providing concurrency and race condition guarantees. This document explains the features and benefits of KOS callbacks and shows how they can be used to solve typical and challenging control system problems.