Article View: borland.public.cppbuilder.internet.socket
Article #1515Is this Indy code safe?
From: Dennis Jones
Date: Fri, 12 Jan 2007 17:51
Date: Fri, 12 Jan 2007 17:51
19 lines
1544 bytes
1544 bytes
Hello,
Is the following code (from Indy 9) safe, or is it possible for the
TCPServer->Threads 'Count' to change between the LockList() and UnlockList()
calls? (this code is in a message handler function that is called as the
result of a PostMessage, so it runs in the context of the main thread)
TList *pThreadList = TCPServer->Threads->LockList();
int Count = pThreadList->Count;
for ( int c=0; c<Count; ++c )
{
TIdPeerThread *pPeerThread = static_cast<TIdPeerThread
*>(pThreadList->Items[c]);
// do something with the thread
}
TCPServer->Threads->UnlockList();
- Dennis
Technical Details
Message-ID:
<45a7ca99$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,3cb86166c3ef0c03,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Dennis Jones" <nospam@nospam.com> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Is this Indy code safe? Date: Fri, 12 Jan 2007 09:51:33 -0800 Lines: 21 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3028 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 NNTP-Posting-Host: 71.245.109.58 Message-ID: <45a7ca99$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1168624281 71.245.109.58 (12 Jan 2007 09:51:21 -0800) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail