🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Affecting a TThread owned variable

#9564
From: Bob Gonder
Date: Sun, 04 Jul 2004 16:25
22 lines
1870 bytes
Ron Sawyer wrote:

>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?

Mutex
Whoever grabs the mutex adds their struct then releases the mutex.

>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?

Two ideas here.
1)Use the same mutex:
	Read the data, Grab the Mutex, Delete, Release.
2)Or, Read the Data, Then set a flag in the structure telling the
thread that the block is waste, and the thread deletes it (or recyles
it) when it gets around to it.
Technical Details
Message-ID: <cfbge01d5cdieh3dqbdqd4k7d85nmr6k5b@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40e80626@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,de47f0217318ee58
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Affecting a TThread owned variable
Date: Sun, 04 Jul 2004 09:25:46 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <cfbge01d5cdieh3dqbdqd4k7d85nmr6k5b@4ax.com>
References: <40e80626@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 65.40.245.85
X-Trace: newsgroups.borland.com 1088958344 65.40.245.85 (4 Jul 2004 09:25:44 -0700)
Lines: 24
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail