[omniORB] omnithread creation

Duncan Grisby dgrisby@uk.research.att.com
Wed, 09 May 2001 17:43:13 +0100


On Wednesday 9 May, Ben Miller wrote:

> This is C++ related and as such is nothing to do with omniORB or
> CORBA.  Briefly, the reason it will not compile with a non-static
> member function of a class is that this function will expect the
> 'this' pointer to be passed in as the first parameter to it.   There
> is no way that omni_thread::create knows that its first parameter
> belongs to a specific instance of your class.  Using a static class
> member function is okay because it does not expect the 'this' pointer.

What Ben says is true. For various reasons, including this one, it's
usually far better to derive a class from omni_thread, rather than
creating a base omni_thread instance, passing in a function pointer.
That way, you just provide a run() member function to your class, and
it gets called when the thread is started.

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --