Article View: borland.public.cppbuilder.oodesign
Article #53Re: Problem with accessing Queue from worker thread
From: Mark Guerrieri
Date: Thu, 31 Mar 2005 22:57
Date: Thu, 31 Mar 2005 22:57
101 lines
4320 bytes
4320 bytes
FYI- have a look at TCriticalSection (or TCOMCriticalSection) for a pre-made
critical section class...
Mark
"Daniel Stevenson" <d.stevenson@ocreage.com.au> wrote in message
news:42408739$1@newsgroups.borland.com...
> Thank you very much, I thought I needed an extern declaration which I
tried
> but i wasn't declaring the object in the cpp file correctly.
>
> Thanks heaps, its all working now.
>
> "Eelke" <e.klein@mplussoftware.nl> wrote in message
> news:423fc937$1@newsgroups.borland.com...
> >
> > > 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:
<424c8049$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<423f6b65@newsgroups.borland.com> <423fc937$1@newsgroups.borland.com> <42408739$1@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 From: "Mark Guerrieri" <mguerrieri@nospam_cmsgrp.com> Newsgroups: borland.public.cppbuilder.oodesign References: <423f6b65@newsgroups.borland.com> <423fc937$1@newsgroups.borland.com> <42408739$1@newsgroups.borland.com> Subject: Re: Problem with accessing Queue from worker thread Date: Thu, 31 Mar 2005 17:57:21 -0500 Lines: 103 Organization: Creative Marketing Strategies X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 209.50.174.82 Message-ID: <424c8049$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1112309833 209.50.174.82 (31 Mar 2005 14:57:13 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail