Article View: borland.public.cppbuilder.oodesign
Article #49Re: Problem with accessing Queue from worker thread
From: Eelke
Date: Tue, 22 Mar 2005 07:29
Date: Tue, 22 Mar 2005 07:29
70 lines
3471 bytes
3471 bytes
> I don't think there is anything wrong with the above declaration, I included
> this to reduce the number of questions in this area.
> I think the problem is in how I've declared my queue but I'm having a brain
> freeze and can't think straight to work out my problem as seen below.
>
>
> ....LoggingServiceSource.h...
> //--------------------------------------------------------------------------
> -
> #ifndef LoggingServiceSourceH
> #define LoggingServiceSourceH
> //--------------------------------------------------------------------------
> -
> #include <SysUtils.hpp>
> #include <Classes.hpp>
> #include <SvcMgr.hpp>
> #include <vcl.h>
> #include "thdLoggingSource.h"
> #include <OleServer.hpp>
> #include <queue>
> using namespace std;
> //--------------------------------------------------------------------------
> -
> TLogQueue<LogStruct> LogQueue; //declaring my queue
> //--------------------------------------------------------------------------
> -
> class TLoggingService : public TService
> {
> __published: // IDE-managed Components
> TatSystemStatus *atSystemStatus;
> TatPagingSubscription *atPagingSubscription;
> void __fastcall atSystemStatusSystemStatus(TObject *Sender,
> atSystemStatusType StatusType, BSTR Origin,
> atSystemStatusLevel Level, BSTR Description);
> void __fastcall atPagingSubscriptionPaging(TObject *Sender,
> BSTR CallNumber, BSTR DisplayMessage, long Priority,
> PagingInfoStruct *AdditionalInfo);
> private: // User declarations
> TLoggingThread *LoggingThread;
> String ConnectionStatus;
>
> void __fastcall UpdateServiceDescription(TService *Sender);
> void __fastcall CreateWorkerThread();
> void __fastcall CheckSystemStatus();
> public: // User declarations
> __fastcall TLoggingService(TComponent* Owner);
> TServiceController __fastcall GetServiceController(void);
>
> friend void __stdcall ServiceController(unsigned CtrlCode);
> };
> //--------------------------------------------------------------------------
> -
> extern PACKAGE TLoggingService *LoggingService;
> //--------------------------------------------------------------------------
> -
> #endif
>
You declared the queue in the header which causes each cpp which
includes this header to get its own copy. Change the declaration to
extern TLogQueue<LogStruct> LogQueue;
and put
TLogQueue<LogStruct> LogQueue;
in one cpp.
Eelke
Technical Details
Message-ID:
<423fc937$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<423f6b65@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,62ae9303d665b63f X-Google-Attributes: gid10db1e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 22 Mar 2005 08:29:34 +0100 From: Eelke <e.klein@mplussoftware.nl> User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.oodesign Subject: Re: Problem with accessing Queue from worker thread References: <423f6b65@newsgroups.borland.com> In-Reply-To: <423f6b65@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.58.1.162 Message-ID: <423fc937$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1111476535 81.58.1.162 (21 Mar 2005 23:28:55 -0800) Lines: 70 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail