CORBA 2.6.1 Programmer's Guide for C++

communication between components that use CORBA. The event framework is a low-level mechanism that does
not require (but does enable) both communicating components to use CORBA.
To provide an optimal tradeoff between coding, performance, and scalability within a process, the event framework uses a hybrid asynchronous
(event-driven) and synchronous (threaded) approach. The NonStop CORBA ORB library consists of:
An asynchronous core that monitors and internalizes outside events
A synchronous CORBA API layer that transforms asynchronous events into a threaded synchronous paradigm.
Event Core
The event core, which cooperates with pthreads T1248 threading mechanism, is a combination of the following:
The null thread from the pthread package
An assortment of NonStop CORBA classes that interact with pthread functions
Data structures that affect the behavior of the null thread
The event core consists of several layers.
For further information about the pthread mechanism (T1248), refer to the Open System Services Programmer's Guide (Section 11).
Null Thread
In a NonStop CORBA process, the null thread is launched during the operation of the ORB_init() method. Its purpose is to map I/O completions
to logical events, getting the next I/O event each time it goes through its loop. The null thread runs at the lowest priority and loops through the
following steps:
Calls a timer method to get a wait interval, representing the shortest amount of time the currently running process will wait for an I/O
event.
Calls the Guardian FILE_COMPLETE_ procedure, passing it the wait interval and a collection of OSS file descriptors and Guardian file
numbers. The Guardian file-number parameters are provided to the pthread package by the creator of the I/O event.
Maps the results of the FILE_COMPLETE_ call to a registered event-handler function, then calls that function with the remaining
FILE_COMPLETE_ results.
Calls the pthread yield() function to allow any accumulated work to be performed by other threads.
Event Types
A process acting as an event handler registers interest in an event with the event core. When that event occurs, the event core makes an upcall
to the registered event handler. The types of events that an event handler can register with the core are:
Time
“Tell me when n ticks have elapsed.”
Outside of the ORB internals,
Fw_Timer events are most often used in their derivative form, NSDEFw_Timer, which blocks a thread for a
specified interval. This usage is described in
Using a Timer for a Thread.
Socket I/O
“Tell me when a completion occurs on socket n.”
The key for socket events is the socket number and the type of socket operation, or affinity (Listen, Connect, Read, Write, or Exception).
Guardian client I/O
“Tell me when a nowait I/O operation I initiated completes.”
Nowait FILE_OPEN_, WRITEREAD, SERVERCLASS_SEND_, and similar operations use the file number and tag as the key that maps
a completion to an event.
Guardian server I/O
“Tell me when an open message for subdevice x is pulled from $RECEIVE” and “Tell me when a WRITEREAD message for session yz
(corresponding to a particular OPEN) is pulled from $RECEIVE.”
Part of the event core is a component that manages $RECEIVE as a special form of Guardian client I/O. The $RECEIVE event handler
that is part of the event framework opens $RECEIVE and keeps a READUPDATE call posted against it. When a READUPDATE call
completes, the $RECEIVE event handler determines which kind of message was received, creates an event, and delivers it to the event
handler (if any) registered to handle the message.
Layers of the Event Core
At the center of the event core is the null thread and the data structures it works with. The core parts of the NonStop CORBA timer, socket, and
file-system client components wrap the pthread API with classes that provide an abstraction of the various events. The TS/MP client event
components are derived from file-system client events. The file-system server event abstraction is built as a user of file-system client events to
manage $RECEIVE.
I/O Event-Handler Framework
The I/O event-handler framework is a set of classes that use the event core to provide an abstraction of the work required to create connections