
| Subject: | Broadcast Concept question.. |
| Posted by: | Gordon Hamm (firebirdwebg…@hotmail.com) |
| Date: | Mon, 29 Sep 2008 |
I have written a broadcast app from scratch, works perfect, but wondering if
Im doing it propertly..
I have 500 clients that reside over the Internet. UDP is out of the question
in this case.
Each connects to my server, the server spawns a thread. The connection is
maintained, via keep alive pings and a control loop.
Each thread then Waits for an event to fire using a TEvent., to wake up etc.
On my server, on the main thread, a user can push a button to send a message
(Keeping it simple)
When the button is pushed, the Global Tevent is fired , waking up the
threads and the message is sent to all 500..
The issue that Im wondering about is this..
I have Global record that is filled in with data on the main thread.. the
data to be sent to the 500 clients..
In each thread I have an exact stucture type of that data...
When the event is fired, all 500 threads move into action, as they should..
Each one uses a critical section to copy the global record (containing the
global data to be sent) the local record...
In my 500 threads..
EnterCriticalSection(My_CS);
try
LocalversionRecord := GlobalRecord;
finally
LeaveCriticalSection(My_CS);
end;
The local rec is then sent to the connected user..No problem..
Im wondering however , that since all 500 threads are going to fire at once,
and each will be requesting the CS at once, will this create a bottleneck?
Maybe its so fast, it doesnt matter. but just wondering..
Is there a more elegant way of getting my global var to each of my threads
other than using a CS?
Craig