[omniORB] question re: threading

David Riddoch djr@uk.research.att.com
Mon, 8 Nov 1999 08:55:45 +0000 (GMT)


On Fri, 5 Nov 1999, Matt Goodall wrote:

> David Riddoch wrote:
> 
> ... lot's of stuff removed ...
> 
> > If you use omniORB 3 (available via CVS and snapshots) you will be able to
> > have single-threaded object implementations or multi-threaded ones, as
> > described in the POA specification.
> 
> Does that mean that it will be possible to bind omniORB to an event
> driven system? I'm thinking of X11 and GTK+ on Linux.

This is a tricky one.  Just because omniORBs calls are single-threaded
with respect to one-another does not mean that they are single-threaded
with respect to other parts of the system, no.

To use omniORB with something like X11 or GTK+ you need to do the
following:

  1.  Initialise the ORB.
  2.  Initialise your widget library and go into your main event loop.
  3.  Calls to the ORB will arrive asynchronously.  You have to ensure
that an interaction between these calls and your widget library are thread
safe.  Most widget libraries are not thread safe.  Recent releases of X11
are partially thread-safe if compiled with this support -- in which case
you can safely post a message to yourself from a CORBA call, and handle it
in your main event loop.  I'm not sure if such a facility exists in GTK+.

      If not then you need to find another way to pass data between CORBA
calls and your event loop.  One way is to use a typical concurrency
controlled loop which you poll periodically.  A better way is to use a
pipe -- most widget libraries will have a way to do a select on a file
descriptor within the event loop.


This is quite a commonly asked question.  I wonder if anyone has a simple
example that they would be prepared to let others see and learn from?


Cheers,
David