...

/

Investigate a Pattern for Event Driven Applications

Investigate a Pattern for Event Driven Applications

In this lesson, we will investigate a pattern for event-driven applications.

Implementing Reactor

In this lesson, we’ll step outside the domain of standard C and investigate a pattern for event-driven applications. The Reactor pattern decouples different responsibilities and allows applications to demultiplex and dispatch events from potentially many clients.

The case of many clients

Diagnostics of individual subsystems are gathered in one central unit to simplify the maintenance of large systems. Each subsystem connects to the diagnostics server using TCP. As TCP is a connection-oriented protocol, the clients (the different subsystems) have to request a connection at the server. Once a connection is established, a client may send diagnostics messages at any time.

The brute-force approach scans for connection requests and diagnostics messages from the clients one by one as illustrated in the activity diagram in Illustration 1.

Even in this strongly simplified example, there are several potential problems. Several ...