[omniORB] Multithreading

Ulf Stoermer ulf@emi.yamaha.co.jp
Tue Nov 19 00:43:00 2002


Hi Uli,

you actually don't need the call to orb->run().
OmniORB is multithreaded anyway and starts it's own
threads to manage requests. Even though orb->run()
is used in all the omni examples it basically just
emulates an idle loop.
So all you need to do is init the ORB and activate
the POA (maybe in your InitInstance function) and
then just run the Windows messages loop.

Cheers

Ulf

> -----Original Message-----
> From: omniorb-list-admin@omniorb-support.com
> [mailto:omniorb-list-admin@omniorb-support.com]On Behalf Of Uli Syber
> Sent: Monday, 18 November 2002 11:55 PM
> To: omniorb-list@omniorb-support.com
> Subject: [omniORB] Multithreading
>
>
> 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
>
>
>
>
> _______________________________________________
> omniORB-list mailing list
> omniORB-list@omniorb-support.com
> http://www.omniorb-support.com/mailman/listinfo/omniorb-list
>