W
WangZhaoHui
Unregistered / Unconfirmed
GUEST, unregistred user!
由于我同时要有八个客户端实时的发送数据,我在服务端接收时,有时由于处理压力过大,可能会导致全局变量被改写。我已经建立接收缓冲区,所以我希望线程同步,我问的是用哪种方案最好,由于我在execute中执行的过程有参数,可能用不了Synchronize,我是用阻塞,互斥,信号量哪一种好呢。代码怎么写
Clients是一个全局的ThreadList,我主要是怕它的信息被改写。
procedure TfrmMain.TCPServerExecute(AThread: TIdPeerThread);
var
ActClient: PClient;
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
AThread.Connection.ReadBuffer(ReceiveData, SizeOfReceiveData);
ActClient := PClient(AThread.Data);
处理接收数据存入缓冲区。....
end;
end;
Clients是一个全局的ThreadList,我主要是怕它的信息被改写。
procedure TfrmMain.TCPServerExecute(AThread: TIdPeerThread);
var
ActClient: PClient;
begin
if not AThread.Terminated and AThread.Connection.Connected then
begin
AThread.Connection.ReadBuffer(ReceiveData, SizeOfReceiveData);
ActClient := PClient(AThread.Data);
处理接收数据存入缓冲区。....
end;
end;