1xpamainloop(3)                SAORD Documentation               xpamainloop(3)
2
3
4

NAME

6       XPAMainLoop: optional main loop for XPA
7

SYNOPSIS

9         #include <xpa.h>
10
11         void XPAMainLoop();
12

DESCRIPTION

14       Once XPA access points have been defined, a program must enter an event
15       loop to watch for requests from external programs. This can be done in
16       a variety of ways, depending on whether the event loop is processing
17       events other than XPA events.  In cases where there are no non-XPA
18       events to be processed, the program can simply call the XPAMainLoop()
19       event loop.  This loop is implemented essentially as follows (error
20       checking is simplified in this example):
21
22         FD_ZERO(&readfds);
23         while( XPAAddSelect(NULL, &readfds) ){
24           if( sgot = select(swidth, &readfds, NULL, NULL, NULL) >0 )
25             XPAProcessSelect(&readfds, 0);
26           else
27             break;
28           FD_ZERO(&readfds);
29         }
30
31       The XPAAddSelect() routine sets up the select() readfds variable so
32       that select() will wait for I/O on all the active XPA channels.  It
33       returns the number of XPAs that are active; the loop will end when
34       there are no active XPAs. The standard select() routine is called to
35       wait for an external I/O request.  Since no timeout struct is passed in
36       argument 5, the select() call hangs until there is an external request.
37       When an external I/O request is made, the XPAProcessSelect() routine is
38       executed to process the pending requests.  In this routine, the maxreq
39       value determines how many requests will be processed: if maxreq <=0,
40       then all currently pending requests will be processed.  Otherwise, up
41       to maxreq requests will be processed.  (The most usual values for
42       maxreq is 0 to process all requests.)
43
44       If a program has its own Unix select() loop, then XPA access points can
45       be added to it by using a variation of the standard XPAMainLoop:
46
47         XPAAddSelect(xpa, &readfds);
48         [app-specific ...]
49         if( select(width, &readfds, ...) ){
50           XPAProcessSelect(&readfds, maxreq);
51           [app-specific ...]
52           FD_ZERO(&readfds);
53         }
54
55       XPAAddSelect() is called before select() to add the access points.  If
56       the first argument is NULL, then all active XPA access points are
57       added. Otherwise only the specified access point is added.  After
58       select() is called, the XPAProcessSelect() routine can be called to
59       process XPA requests.  Once again, the maxreq value determines how many
60       requests will be processed: if maxreq <=0, then all currently pending
61       requests will be processed.  Otherwise, up to maxreq requests will be
62       processed.
63
64       XPA access points can be added to Xt event loops (using
65       XtAppMainLoop()) and Tcl/Tk event loops (using vwait and the Tk loop).
66       When using XPA with these event loops, you only need to call:
67
68       int XPAXtAddInput(XtAppContext app, XPA xpa)
69
70       or
71
72         int XPATclAddInput(XPA xpa)
73
74       respectively before entering the loop.
75

SEE ALSO

77       See xpa(n) for a list of XPA help pages
78
79
80
81version 2.1.15                   July 23, 2013                  xpamainloop(3)
Impressum