[omniORB] Threads in ORB
jorgefm@cirsa.com
jorgefm@cirsa.com
Mon, 29 Apr 2002 15:44:33 +0200
(Sorry i made a mistake with the cut&paste with the function's name
'RegisterOnStatusChanged')
Hi folks !
I have a little newbie question about threads and registered objects in
OmniORB. I don't know
if i can post code excerpts.
I have this interface :
interface ICorbaClient {
oneway void OnStatusChanged(in boolean new_status);
};
interface ICorbaServer {
boolean RegisterOnStatusChanged(in ICorbaClient client);
};
There is a client and a server. I create clients' instances that i register
in a remote server to be
notified by the server when a status change is detected. In my client code
i have defined the next class
to manage the corba client :
class __IClient : public virtual POA_ICorbaClient,
public virtual PortableServer::RefCountServantBase
{
public:
__IClient();
virtual ~__IClient();
virtual void Initialize();
virtual void RegisterOnStatusChanged();
// Interface idl.
virtual void OnStatusChanged(CORBA::Boolean new_status);
private:
ICorbaClient_ptr m_sink;
ICorbaServer_ptr m_server
};
void __IClient::Initialize()
{
// Activate the servant.
poa->activate_object( this );
// Generate a local reference.
m_client_ptr = _this();
// _this() calls _duplicate(), then we have to free one reference.
_remove_ref();
// Get server reference.
CORBA::Object_var obj = CORBAGetObjectReference( "TestServer" );
m_server = ICorbaServer::_narrow(obj);
}
void __IClient::RegisterOnStatusChanged()
{
m_server->RegisterOnStatusChanged( m_client_ptr );
}
void __IClient::OnStatusChanged(CORBA::Boolean new_status)
{
printf( "[pid : %d] Status changed !\n", getpid() );
}
Where 'CORBAGetObjectReference' gets a servant reference from the Name
Service
previosuly registered. Then when i want to create a new client and register
it i do :
__IClient *client = new __IClient();
client->Initialize();
client->RegisterOnStatusChanged();
My question is about the PID i get in the 'OnStatusChanged' notification
function. It's the same for all the
clients ! Is it normal ? I expected one thread per client, but i think that
all the clients share the same connection
with the server although every clients gets it's own server reference !
Thanks for all,
Jorge