Corba & MultiThreading (was Re: Orb choosing time)



Philip Dawes wrote:
> 
> - When a corba application calls boa->impl_is_ready() it blocks
>         (waiting to serve messages from other corba objects).
> - When a gtk application calls gtk_main_loop() it blocks
>         (waiting to serve events from X).
> 
> Therefore we can't have a interactive corba-enabled gtk application in a
> single process without threads.
> 
> Cheers,
> 
> Phil.
> 

Having put the frightners up the entire don't-like-mt-code gnome
developer community, here's my suggestions for some ways around the
problem if you don't want to write multi-threaded code:

1) Hack the code for both gtk and mico/omniorb to combine both blocking
calls into one super gnome gtk/corba blocking call. (processes the gtk
loop, then processes the omniorb loop). 
Unfortunately this will require both loops to be non-blocking, and may
invove select() and the like.

2) Have a simple gnome_main_loop function which creates two threads,
calls boa->impl_is_ready() on one and gtk_main_loop on the other, then
synchronises them with a semaphore (i.e. only one thread can execute at
a time). This should effectively render the actual application code
single-threaded.

I think the second is much safer - I've tried to make the
gtk_main_loop() function non-blocking in the past with slightly unstable
consequences. I'll test this out tomorrow night and mail back the
results on Monday. 
(I'm going out tonight -  gnome developer has a life shocker!)

Cheers,

Phil

-- 
_______________________________________________________________________
 Phil Dawes                               |   My opinions are my own
 WWW:    err.. temporarily non-existant   |   and nothing to do with
 Email:  philipd@parallax.co.uk           |      my employer.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]