Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Sep : Re: Accessing a central resource?

www.cryer.info
Managed Newsgroup Archive

Re: Accessing a central resource?

Subject:Re: Accessing a central resource?
Posted by:"Remy Lebeau (TeamB)" (no.spam@no.spam.com)
Date:Fri, 14 Sep 2007 00:54:10

"Toby Piper" <news@CompCraft.com> wrote in message
news:46ea07cc$1@newsgroups.borland.com...

> I can't find ANY examples that deal with sharing a
> resource between the threads and synchronizing accesses.

Then you are not looking in the right places, because examples are posted
all the time.  There are hundreds of examples in the newsgroup archives, and
in various websites.

Have a look at the TThreadList class.  It is a TList with a critical section
wrapped around it.  Give all of your threads their own local TThreadList
instance.  Wrap your request and response data in a record or object.  Store
the original client thread pointer as a member.  When your server receives a
request from a client, store an instance of the request info into the
TThreadList of the thread that is managing the connection to the other
server.  That thread can continuously check its list for new requests and
handle them as needed.  When a response arrives, it will know which
TThreadList of which thread to forward the response info to.  The OnExecute
event for each client thread can then check its respective list for new
responses and send them to the client as needed.


Gambit

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive