[omniORB] Efficient single thread use of omniORB...

Duncan Grisby duncan at grisby.org
Fri Oct 28 16:09:32 BST 2005


On Thursday 27 October, Michael Burbidge wrote:

> I'm trying to implement a fairly large Corba API in a legacy
> application. I say legacy, because the application is not thread
> safe. All processing must be done in the main thread. This
> application has a sophisticated idle task architecture for doing
> background processing. It was relatively easy for me to get omniOrb
> working using work_pending and perform_work. However it is proving to
> be fairly difficult to get it working efficiently.

I assume you're using a POA with the MAIN_THREAD_MODEL threading
policy. If not, omniORB is busy dispatching calls on its own threads
regardless of whether you're calling perform_work...

[...]
> What would really be nice, is if omniORB provided another function
> that would work in conjunction with work_pending. This function would
> block waiting for a corba request. When a request came in it would
> unblock and return, with the expectation that the request would then
> be processed by perform_work. The function would be called something
> like wait_for_work.

The way the main thread policy works is that most of the work of
handling a call is still done in threads created by omniORB. Only the
actual call into application code is handled by the main thread. The
main thread is given the work to do by the ORBAsyncInvoker that you can
see in src/lib/omniORB/orbcore/corbaOrb.cc. The job is inserted with
insert_dedicated(), then handled in the perform() method.

If you want a different thread to be able to block waiting for the main
thread to have work, you just need to add a function that blocks on the
invoker_signal condition variable. Alternatively, you could perhaps
modify the insert_dedicated function to signal your application's event
loop.

[ As an aside, notice that if a thread other than the main thread calls
work_pending(), it always returns false, since omniORB never uses
application threads other than the main thread. ]

As far as I'm aware, very few people use the main thread model, so I'm
not keen to add any non-standard functionality to it, unless lots of
people ask for it. Obviously, it's fine for you to add it for yourself.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list