home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!uwm.edu!ogicse!mintaka.lcs.mit.edu!bloom-beacon!INTERNET!dont-send-mail-to-path-lines
- From: deveau@oceanroutes.ns.ca ("Terry J. Deveau")
- Newsgroups: comp.windows.x
- Subject: Re: XtAddInput or XtAddTimeout question
- Message-ID: <9208281452.AA00286@expo.lcs.mit.edu>
- Date: 28 Aug 92 14:51:46 GMT
- Article-I.D.: expo.9208281452.AA00286
- References: <38184@unix.SRI.COM>
- Sender: deveau@oceanroutes.ns.ca
- Organization: Oceanroutes Canada Inc.
- Lines: 29
-
- ric steinberger <ric@updike.sri.com> writes:
- >
- > I would "like" to use XtAddInput() to allow an X application to
- > read data from a (IPC) message queue. The man page specifies that the first
- > argument needs to be an integer file descriptor for a file that is
- > expecting data to be read or written (essentially).
- >
- > What I would like to do (instead) is to check whether there are any
- > messages (of a given type) pending in a message queue. I would need to use
- > the system call msgrcv() to do this. Since message queues do not use file
- > descriptors, using XtAddInput may be problematic. [Conceivably,
- > I could have the sending process write to a file that the receiving process
- > has open, but that seems convoluted].
- >
- > Instead, I am thinking of using XtAddTimeout() to check the message
- > queue every few seconds. XtAddTimeout() would supply the name of a
- > routine that executes a non-blocking msgrcv() call, processes any
- > messages, then re-establishes XtAddTimeout(). This is polling, clear and
- > simple, am I can probably live with it.
- >
- > My question: Is this (polling) the best way to go? Has anyone else
- > used message queues in X applications and found a more elegant way to be
- > notified of the presence of a message of a particular type (or lacking that,
- > any message at all)? Thanks for any suggestions. Please reply to the
- > address below.
- >
- What I do is set IPC_NOWAIT on the call to msgrcv() and use XtAddAppTimeout
- to poll the message queue every 125 to 500 ms (depending on what else I'm
- trying to accomplish while waiting for messages). It works great. ... Terry
-