🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.multi-tier
5 messages
5 total messages Started by vavan Thu, 27 Dec 2001 07:38
Survey of using MIDAS with anything other than single-threading in BCB - Revisited
#309
Author: vavan
Date: Thu, 27 Dec 2001 07:38
5 lines
1174 bytes
So, after years of silence :), is there anybody who succeeded in
business?

--
Vladimir Ulchenko aka vavan
Re: Survey of using MIDAS with anything other than single-threading in BCB - Revisited
#310
Author: vavan
Date: Fri, 28 Dec 2001 09:58
10 lines
1266 bytes
On Thu, 27 Dec 2001 10:38:36 +0300, vavan <vavan@santel.ru> wrote:

>So, after years of silence :), is there anybody who succeeded in
>business?

Well, I'll post the solution ASAP. One good guy with good knowledge of
ATL (many thanks Alex Rabiciuc!!!) pointed me to that

--
Vladimir Ulchenko aka vavan
Re: Survey of using MIDAS with anything other than single-threading in BCB - Revisited
#312
Author: vavan
Date: Thu, 03 Jan 2002 14:01
104 lines
3881 bytes
On Thu, 27 Dec 2001 10:38:36 +0300, vavan <vavan@santel.ru> wrote:

OK, here's the magic.

You need to include following source file in the AppServer project

#include "raATLCOM.h"
HRESULT CRaComThreadModule::Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h,
const GUID* plibid)
{
        CComApartment::ATL_CREATE_OBJECT =
RegisterWindowMessage(_T("ATL_CREATE_OBJECT"));
        return CComModule::Init(p, h, plibid);
};

HRESULT CRaComThreadModule::CreateInstance(void* pfnCreateInstance,
REFIID riid, void** ppvObj)
{
        _ATL_CREATORFUNC* pFunc = (_ATL_CREATORFUNC*)
pfnCreateInstance;
        _AtlAptCreateObjData data;
        data.pfnCreateInstance = pFunc;
        data.piid = &riid;
        data.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
        data.hRes = S_OK;
        CComApartment m_pApartment;
        m_pApartment.m_hThread = CreateThread(NULL, 0,
CComApartment::_Apartment, (void*)&m_pApartment, 0,
&m_pApartment.m_dwThreadID);
        while (!::PostThreadMessage(m_pApartment.m_dwThreadID,
CComApartment::ATL_CREATE_OBJECT, 0, (LPARAM)&data))
          ::Sleep(100);
        AtlWaitWithMessageLoop(data.hEvent);
        CloseHandle(data.hEvent);
        if (SUCCEEDED(data.hRes))
                data.hRes =
CoGetInterfaceAndReleaseStream(data.pStream, riid, ppvObj);
        return data.hRes;
}

LONG CRaComThreadModule::Unlock()
{
        LONG l = CComModule::Unlock();
        DWORD dwThreadID = GetCurrentThreadId();
        ::PostThreadMessage(dwThreadID, WM_QUIT, 0, 0);
        return l;
};
//****************************************************************

..and here's the header

#ifndef _RAATLCOM_H
#define _RAATLCOM_H

#include <utilcls.h>
#include <atl\atlbase.h>

#ifndef RA_SINGLETHREADED_DCOM
        #define TRaATLModule TATLModule<CRaComThreadModule>
        #define DECLARE_RA_CLASSFACTORY()
DECLARE_CLASSFACTORY_AUTO_THREAD()
#else
        #define TRaATLModule TATLModule<CComModule>
        #define DECLARE_RA_CLASSFACTORY() DECLARE_CLASSFACTORY()
#endif


class CRaComThreadModule : public CComModule
{
public:
	HRESULT Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, const GUID*
plibid = NULL);
	HRESULT CreateInstance(void* pfnCreateInstance, REFIID riid,
void** ppvObj);
	LONG Unlock();
};

#endif

in the YourAppServerObjectImpl.h file you should insert the line
DECLARE_RA_CLASSFACTORY() in the public section of class ATL_NO_VTABLE
TYourAppServerObjectImpl: REMOTEDATAMODULE_IMPL(...

...and the last but not the least...

you need to patch atlmod.h (sorry, borland)

just comment out
//typedef TATLModule<CComModule> TComModule;

and insert
#include <raATLCOM.h>
typedef TRaATLModule TComModule;

right before the line
extern TComModule &_Module;

that's all folks, and HTH 


Any remarks and opinions very appreciated

--
Vladimir Ulchenko aka vavan
Re: Survey of using MIDAS with anything other than single-threading in BCB - Revisited
#314
Author: Hans-Joachim Herholz
Date: Fri, 04 Jan 2002 01:53
13 lines
1680 bytes
First of all: the 'magic' really works!
I've tried it in a larger project with some 20 RDMs and now all the clients
are really served simultaneously.

Good job Vladimir!

One little point: when the last clients exits from the application and the
server.exe closes there are sometimes 'unknown software exceptions' which
are not there without these changes.

Greetings

Hans-Joachim
Re: Survey of using MIDAS with anything other than single-threading in BCB - Revisited
#315
Author: vavan
Date: Fri, 04 Jan 2002 07:57
22 lines
1803 bytes
On Fri, 4 Jan 2002 02:53:44 +0100, "Hans-Joachim Herholz"
<herholz@t-online.de> wrote:

>First of all: the 'magic' really works!
>I've tried it in a larger project with some 20 RDMs and now all the clients
>are really served simultaneously.
>
>Good job Vladimir!

Thanks to Alex!

>One little point: when the last clients exits from the application and the
>server.exe closes there are sometimes 'unknown software exceptions' which
>are not there without these changes.

Please investigate if possible.. Since your AppServer is really
multithreaded now there could be potential errors which were invisible
before? BTW, I have a little problem when trying to send the message
to the main form when the instance of RDM is destroyed..

--
Vladimir Ulchenko aka vavan
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads