Article View: borland.public.cppbuilder.nativeapi
Article #2076Re: Need help with Mutex
From: Bob Gonder
Date: Sun, 29 Apr 2007 15:43
Date: Sun, 29 Apr 2007 15:43
23 lines
1857 bytes
1857 bytes
JD wrote: >Bob Gonder wrote: >> >> [...] which you don't use CloseHandle on, so are leaking >> resources > >From win32.hlp CreateMutex: And your point is? That the mutex is released if he closes the handle? My point was he was creating 2 handles for every lock/release, and never closing them. Won't take long to run out of handles. In my final example I showed how to create/leak only one handle per TCriticalSection object, no matter how many times it was used. Acceptable for testing purposes, as a few leaked handles shouldn't create it's own set of problems (like the run-away handles could). For on-going usage, I'd make the handle part of the class and have the destructor close it. But then, I prefere to write in a non-deadlocking manner in the first place.
Technical Details
Message-ID:
<62e933pksdsi46q91i5nhbektbvpt3ecem@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4633777f$1@newsgroups.borland.com> <aev6339dmkoh5ih93feqeofs77v59f6iic@4ax.com> <4634b554$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,28184df4065864d1 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: Need help with Mutex Date: Sun, 29 Apr 2007 08:43:59 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <62e933pksdsi46q91i5nhbektbvpt3ecem@4ax.com> References: <4633777f$1@newsgroups.borland.com> <aev6339dmkoh5ih93feqeofs77v59f6iic@4ax.com> <4634b554$1@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: 67.77.147.157 X-Trace: newsgroups.borland.com 1177861437 67.77.147.157 (29 Apr 2007 08:43:57 -0700) Lines: 26 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail