[omniORB] How can I synchronise the Xwindows main loop with omniORB ?

Duncan Grisby dgrisby@uk.research.att.com
Tue, 28 Mar 2000 16:07:13 +0100


On Tuesday 28 March, Eric DARIEL wrote:

> But for refreshing the xwindows objects, I must register 
> the X_main_loop with a file descriptor.
> How can I obtain one from omniORB ?

As I said in my previous reply, you cannot obtain a suitable file
descriptor from omniORB. You should create a pipe, with code like

  #include <unistd.h>

  int pipe_read;
  int pipe_write;

  void initPipe() {
    int filedes[2];
    pipe(filedes);
    pipe_read  = filedes[0];
    pipe_write = filedes[1];
  }

Now you can give X the global pipe_read file descriptor to wait upon.
Whenever you want to wake X up, simply write a character to pipe_write
using write(2). (Remember to read it out of pipe_read from the X
handling thread.) You'll probably need at least one other global
variable to indicate reason for waking X up.

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --