TsgcWebSocketHTTPServer › 属性 › QueueOptions
通过内部每连接队列序列化出站消息,以防止线程间的竞争。
property QueueOptions: TsgcWSQueueServer_Options read FQueueOptions write SetQueueOptions;
Text=qmNone,Binary=qmNone,Ping=qmNone
启用后,消息将放入内部队列,并在连接线程的上下文中发送,而非在调用方线程中发送,从而消除多个线程同时写入同一连接时所需的锁定。每种消息类型(Text、Binary、Ping)可分配独立的优先级:qmNone 跳过队列(默认),qmLevel1 最先处理,其次是 qmLevel2,最后是 qmLevel3。例如,将 Text 和 Binary 设为 qmLevel2,将 Ping 设为 qmLevel1,可保证 ping 先于普通流量投递。当 IOHandlerOptions 设置为 iohIOCP 时,不支持 QueueOptions。
oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.QueueOptions.Text := qmLevel2;
oServer.QueueOptions.Binary := qmLevel2;
oServer.QueueOptions.Ping := qmLevel1;
oServer.Active := true;