🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9563

Affecting a TThread owned variable

#9563
From: Ron Sawyer
Date: Sun, 04 Jul 2004 13:29
22 lines
2010 bytes
I have a TThread that does some processing for me.  It is global to the app,
so that all forms have access to it.  It has a FIFO queue to add structures
for the thread to process. Processing can take varying amounts of time and I
don't want the forms to block while waiting for the processing.

Part of the structure is the Handle of the window that put the structure in
the queue.  When the thread is done processing, it posts a message to the
handle to tell the original form that the data is available.

Everything seems to work.  But I am not sure that I am doing things
correctly.

There is a method in the Thread, lets call it AddStruct, for adding the
structure.  AddStruct is called by the forms to add a structure to the FIFO
for processing.  What must I do to make sure that I am adding things in a
thread-safe manner?

There is a method in the Thread, lets call it DelStruct for getting the
structure out of FIFO.  The form copies the data in the struct in the FIFO
to a local struct and then calls DelStruct to remove the structure from the
FIFO.  What must I do to make sure that I am removing things in a
thread-safe manner?
Technical Details
Message-ID: <40e80626@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,de47f0217318ee58,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Ron Sawyer" <XXXRSAWYER8128XQQXX@aol.com>
From: "Ron Sawyer" <XXXRSAWYER8128XQQXX@aol.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Affecting a TThread owned variable
Date: Sun, 4 Jul 2004 09:29:12 -0400
Lines: 24
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: 172.134.164.65
Message-ID: <40e80626@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1088947750 172.134.164.65 (4 Jul 2004 06:29:10 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail