[omniORB] Single Threaded Policy: really same thread?

Duncan Grisby duncan@grisby.org
Tue Dec 17 20:49:01 2002


On Tuesday 17 December, Kevin Matassa wrote:

> I'm not sure what setMainThread() does?  Am I able to call setMainThread
> from within each instance of my server object, such that all subsequent
> calls to that instance will continue to use the same thread?

The main thread policy dispatches all requests for all objects in the
POAs using that policy on a single identified "main" thread. By
default, that single thread is the one that initialised the omnithread
library at static initialisation time. In a normal executable, that is
the same thread that runs the main() function. If you dynamically load
the omniORB libraries, it will be the thread that did the loading.

If you call setMainThread(), the thread that makes that call becomes
the main thread for all calls in all main thread policy POAs. You can
change it as you're running if you like, but there is no point in
doing that.

You can call orb->run() from as many threads as you like, but only the
one that is the main thread will ever do any work. All the others will
just block waiting for the ORB to be shut down.

It sounds like what you want is thread per servant, which omniORB
doesn't support. It's easy to implement it yourself with a bit of
concurrency control.

Cheers,

Duncan.

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