Natural Access is a collection of re-entrant libraries capable of supporting programming models to suit most application requirements. Natural Access supports single-threaded (single-thread-per-process) as well as multi-threaded (multiple-threads-per-process) applications. It also supports multiple contexts accessing multiple instances of Natural Access Server (ctdaemon) on various hosts.
You can create different programming models using contexts and event queues. This topic contains the following sample programming models:
Variations on these models are also supported.
The one context, one event queue configuration shown in the following illustration is the simplest approach for application development. This model uses multiple application processes, each with its own event queue.
This configuration is best suited to systems with a low number of contexts. Using this configuration, applications can create synchronous wrappers allowing a sequential stateless thread of execution.
Multi-threaded applications use the multiple contexts, multiple event queues configuration shown in the following illustration. Each thread has its own event queue with one context. The thread can be developed with synchronous functions as in the one event queue, one context configuration.
Each thread controls an event queue. A thread can sleep waiting for an event from its services without interfering with the reception of events in other threads.
The multiple contexts, one event queue configuration shown in the following illustration is the most efficient for system resource utilization. The operating system resource demand is minimized at the expense of development complexity.
In this configuration, the queue receives events for all contexts. This approach requires the application to implement a state-machine model.
An application can use services on multiple instances of Natural Access Server (ctdaemon) as shown in the following illustration. Each context is created on a specific server. A single event queue can receive events from contexts created on all specified servers.