[omniORB] Multithreading

Uli Syber uli.syber@schraml.de
Mon Nov 18 14:56:01 2002


Hi,

System:
I use omniORB 4.0.0 on a win 32 architecture. My operation system is WIN 2000 and I use VC++ 6.0:

Problem:
Iīd like to start an omniORB server in my program as a background thread (worker thread). Therefore I have tried the following:



#include <windows.h>
#include <windowsx.h>
#include <stdio.h>
/////////////////////////////////////////////////////////////////////////////////////////////////
class MyClass
{	
	private:			
		CORBA::ORB_var orb;
		static DWORD WINAPI ThreadFunc();
		void startThread();		
		
	public:
		void runORB();

};
/////////////////////////////////////////////////////////////////////////////////////////////////
void MyClass::runORB()
{	
	try
	{		
		cerr << "Server is running!" << endl;
		orb->run();		
	}
	catch(...)
	{
		cerr << "Caught unknown exception." << endl;
	}	
}
DWORD WINAPI MyClass::ThreadFunc()
{	

	runORB();		//Proplem: Isnīt a static member because auf orb->run();

	return((DWORD)0);

} 
void MyClass::startThread()
{		
			
	hThread[0] = CreateThread(NULL,0,MyClass::ThreadFunc,NULL,0,&dwThreadID[0]);		
	WaitForMultipleObjects(	MAX_THREADS,hThread,TRUE,INFINITE);	
	
	printf("Thread is running!");


}

CreateThread(...) need a static function like MyClass::ThreadFunc().Threrefore must runORB() in ThreadFunc() actually also a static method.
But in runORB() I call orb->run() witch gets on the heap. Iīve tried to include CORBA.h to get an instance of ORB_var but it doesnīt work.


Question:
How can I get orb->run() as a background work? 


greetings,
Uli