home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / windows / x / 15835 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  2.1 KB

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