🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Thread synchronisation

#13651
From: Wim Bekker
Date: Thu, 02 Oct 2003 12:01
23 lines
2053 bytes
"Rob" wrote:

> This is a good technique;  it's one I've used regularly.  One potential
> issue
> to be aware of is ensuring that the worker thread does not access the
> "needed values" while the main thread is using them.  I presume this is
> what you mean by a "thread-safe place" eg the needed values
> are protected by a critical section.  There is a slight performance
> overhead with this (it is just a cost of preventing things like
> race conditions).

I protect the data with a TMultiReadExclusiveWriteSynchronizer. The thread
has to ask write lock so the main-thread can still block the thread. For
best performance I let the main-thread perform a copy (Move) of the data and
then proces it further.

> Your statement about the Synchronize() method needs to be stronger:
> it *will* halt the worker thread until the main thread handled the
request.
> That is the whole purpose of the method.

Yep.
Technical Details
Message-ID: <3f7c139e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!newshosting.com!news-xfer1.atl.newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f704989@newsgroups.borland.com> <3f750c0d$2@newsgroups.borland.com> <3f77f4b0@newsgroups.borland.com> <3f796747@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,20b65b563d927a2d
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-02 05:12:07 PST
From: "Wim Bekker" <wim@bekker>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f704989@newsgroups.borland.com> <3f750c0d$2@newsgroups.borland.com> <3f77f4b0@newsgroups.borland.com> <3f796747@newsgroups.borland.com>
Subject: Re: Thread synchronisation
Date: Thu, 2 Oct 2003 14:01:02 +0200
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 212.238.29.217
Message-ID: <3f7c139e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1065096094 212.238.29.217 (2 Oct 2003 05:01:34 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!newshosting.com!news-xfer1.atl.newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail