🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: TTimers and Critical Sections...

#11507
From: Helmut Giese
Date: Fri, 06 Feb 2004 11:52
23 lines
1516 bytes
Hello Mike,
Gambit said a lot of useful things about general design issues for
your situation. I just want to add a little bit of advice.
If you have a variable shared between several threads and filling it
may take some time, I usually use a local copy to work with and update
the shared variable when done. Something like

/* defined somewhere as global variable */
myStruct sharedVar;

void fillStruct( ... ) {
	myStruct localVar;
	/* fill localVar here */
	
	/* make data available to other thread(s) */
	EnterCriticalSection(...);
	sharedVar = localVar;
	LeaveCriticalSection(...);
}

This reduces the time spent in the critical section to the minimum.
HTH
Helmut Giese
Technical Details
Message-ID: <40237df3.2222183@forums.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4022d173$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e86366b203b792f7
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-06 03:54:19 PST
From: hgiese@ratiosoft.com (Helmut Giese)
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: TTimers and Critical Sections...
Date: Fri, 06 Feb 2004 11:52:48 GMT
Message-ID: <40237df3.2222183@forums.borland.com>
References: <4022d173$1@newsgroups.borland.com>
X-Newsreader: Forte Free Agent 1.21/32.243
NNTP-Posting-Host: 80.136.132.86
X-Trace: newsgroups.borland.com 1076068366 80.136.132.86 (6 Feb 2004 03:52:46 -0800)
Lines: 23
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail