[omniORB] Getting ObjectId when using default servant

Stefan Seefeld seefelds@MAGELLAN.UMontreal.CA
Mon, 04 Dec 2000 10:48:19 -0500


Duncan Grisby wrote:
> 
> On Sunday 3 December, randy.shoup@tumbleweed.com wrote:
> 
> > What are the plans for adding support for PortableServer::Current in
> > omniORB3?  What are the technical barriers, if any, to implementing
> > this?  In my naivete, it seems to me that it is just a matter of taking
> > advantage of thread-local storage to store the current POA and object-id
> > during an operation invocation :-).
> 
> It's almost as simple as doing that. The main barrier to it being
> added to omniORB 3.0 is that the omnithread interface has no
> thread-local storage facilities, so there is no way to do it. Once
> that has been added (which it has in the omni4_0_develop branch), the
> main challenge is setting the state in a way which doesn't slow things
> down too much. The other challenge is that calls within a single
> address space don't necessarily happen in threads created by
> omnithread, so attaching state to them is potentially nasty.

why is that ?

In berlin, too, we use a couple of threads spawned by our own library. Yet
we use 'thread ids' for every thread. We do it this way:

inline unsigned long Thread::id()
{
  unsigned long *_id = reinterpret_cast<unsigned long *>(pthread_getspecific(id_key));
  if (!_id)
    {
      MutexGuard guard(id_mutex);
      if (!_id)
	{
	  _id = new unsigned long (counter++);
	  pthread_setspecific(id_key, _id);
	}
    }
  return *_id;
}

and therefor we can assign Ids to any threads, independent of where they are
created.

On a sidenote: we (berlin) too are very much interested into the PortableServer::Current
facility, as we use _this() a lot (visitor pattern etc.). Right now it appears we have 
to cache it, i.e. redefine the _this() method to return the cached value. Instead, the 
proper and fastest way would be to ask the current context for the reference...

Best regards,	Stefan
_______________________________________________________              
              
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds@magellan.umontreal.ca

_______________________________________________________

      ...ich hab' noch einen Koffer in Berlin...