zoukankan      html  css  js  c++  java
  • TRttiContext.DropContext线程不安全

    QC上有人提出,下面两个方法配对调用时,因线程不安全而出错,QC地址:https://quality.embarcadero.com/browse/RSP-27771

    TRttiContext.KeepContext;
    TRttiContext.DropContext;

    我把提出者的代码改了下,测试结果果真如此,下面是测试代码:

    procedure TForm61.Button1Click(Sender: TObject);
    var
     i : Integer;
    begin
      for i := 0 to 1000 do
      begin
    //    TThread.CreateAnonymousThread(
    //      procedure ()
    //      var
    //        j : Integer;
    //      begin
    //        for j := 0 to 100000 do
    //        begin
    //          TRttiContext.KeepContext;
    //          TRttiContext.DropContext;
    //        end;
    //
    //      end
    //    ).Start;
    
      Scheduler.Run(procedure
                    var
                      j : Integer;
                    begin
                      for j := 0 to 100000 do
                      begin
                        TRttiContext.KeepContext;
                        TRttiContext.DropContext;
                      end;
                    end)
               .WhenException(
                               procedure (const AException:Exception)
                               begin
                                    ShowMessage(AException.Message);
                               end).Activate;
    
      end
    
    end;

    运行,会产生大量错误:

    现在,官方Open了这个问题。

    这个bug产生的后果,就是使得WebBroker及DataSnap应用在高并发情况下不稳定。问题提出者也是在做压力测试时发现的问题。在官方未解决前,你能做的就是去投票,督促官方修正。https://quality.embarcadero.com/browse/RSP-27771

    测试环境:Delphi 10.3.3。

  • 相关阅读:
    学期总结
    C语言I博客作业09
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
    C语言博客作业04
    C语言I博客作业03
    C语言I博客作业02
    C语言I博客作业01
    学期总结
  • 原文地址:https://www.cnblogs.com/kinglandsoft/p/TRttiContext_DropContext.html
Copyright © 2011-2022 走看看