🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #54

Re: Problem with accessing Queue from worker thread

#54
From: Daniel Stevenson
Date: Fri, 01 Apr 2005 06:33
119 lines
4771 bytes
Thanks,

I wish I knew about that earlier...at least I've learnt something from all
of this.

"Mark Guerrieri" <mguerrieri@nospam_cmsgrp.com> wrote in message
news:424c8049$1@newsgroups.borland.com...
> 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: <424ceb21@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.agarik.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <423f6b65@newsgroups.borland.com> <423fc937$1@newsgroups.borland.com> <42408739$1@newsgroups.borland.com> <424c8049$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: "Daniel Stevenson" <daniel@ocreage.com.au>
Newsgroups: borland.public.cppbuilder.oodesign
References: <423f6b65@newsgroups.borland.com> <423fc937$1@newsgroups.borland.com> <42408739$1@newsgroups.borland.com> <424c8049$1@newsgroups.borland.com>
Subject: Re: Problem with accessing Queue from worker thread
Date: Fri, 1 Apr 2005 16:33:21 +1000
Lines: 121
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: 202.174.233.53
Message-ID: <424ceb21@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1112337185 202.174.233.53 (31 Mar 2005 22:33:05 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news.agarik.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail