HP-UX SNAplus2 MS Programmer's Guide

Writing MS Applications
Scheduling Asynchronous Events
Chapter 2 45
Multithreaded Applications
SNAplus2 API libraries are available for linking with multithreaded
applications. When you develop applications to operate in a
multithreaded environment, the following restrictions apply:
When an application uses the asynchronous entry point, the
application is required to maintain the consistency of its data
structures when callbacks are invoked. Consistency of data
structures can be maintained using the multithreading lock or
mutex facilities. The callbacks are made in the context of a separate
thread created and managed from within the SNAplus2 API library.
Since asynchronous callbacks run using a separate thread, the
application is not required to provide a source of scheduling to enable
the callbacks. Do not use application scheduling mode in a
multithreaded application.
The application must perform any required cleanup processing (for
example, issuing UNREGISTER_MS_APPLICATION or
UNREGISTER_NMVT_APPLICATION, as appropriate, and issuing
DISCONNECT_MS_NODE) before a thread terminates. The MS
library does not maintain any correlation between threads and MS
verb usage and does not perform this processing automatically when
a thread terminates.
Motif Applications
Applications that use the Motif interface, and whose code therefore
consists mainly of callbacks from the Motif libraries, are required to add
SNA events to the main Xt library scheduling loop. The SNA events
enable the SNAplus2 library to run callbacks in order to process
asynchronous verb completions.
Add the following lines to your code before the first call into any SNA
library:
#include <Xt.h>
int app_context;
...
XtAppInitialize(app_context...)
...
SNA_USE_XT_SCHED(app_context);