You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Anton Shchyrov (JIRA)" <ji...@apache.org> on 2018/03/13 18:01:00 UTC

[jira] [Updated] (THRIFT-4468) Make the class TGUIConsole thread-safe

     [ https://issues.apache.org/jira/browse/THRIFT-4468?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anton Shchyrov updated THRIFT-4468:
-----------------------------------
    Description: 
In Delphi all methods that refer to VCL should do it only from main thread. But class TGUIConsole despite the name does not contain any synchronization methods.

My suggestion is to rename this class to TStringsConsole, make method InternalWrite virtual and make new class TGUIConsole inherits from TStringsConsole

 
{code:java}
TGUIConsole = class( TStringsConsole )
protected
   procedure InternalWrite(const S: string; bWriteLine: Boolean); override;
end;
{ TGUIConsole }
procedure TGUIConsole.InternalWrite(const S: string; bWriteLine: Boolean);
 begin
   if TThread.CurrentThread.ThreadID <> MainThreadID then begin
     TThread.Synchronize(nil, procedure
       begin
         inherited InternalWrite(S, bWriteLine);
       end
     );
   end else
     inherited InternalWrite(S, bWriteLine);
 end;
{code}
 

  was:
In Delphi all methods that refer to VCL should do it only from main thread. But class TGUIConsole despite the name does not contain any synchronization methods.

My suggestion is to rename this class to TStringsConsole, make method InternalWrite virtual and make new class TGUIConsole inherits from TStringsConsole

{{ TGUIConsole = class( TStringsConsole )}}
{{ protected}}
{{  procedure InternalWrite(const S: string; bWriteLine: Boolean); override;}}
{{ end;}}

{{{ TGUIConsole }}}

{{procedure TGUIConsole.InternalWrite(const S: string; bWriteLine: Boolean);}}
{{begin}}
{{  if TThread.CurrentThread.ThreadID <> MainThreadID then begin}}
{{    TThread.Synchronize(nil, procedure}}
{{      begin}}
{{        inherited InternalWrite(S, bWriteLine);}}
{{      end}}
{{    );}}
{{  end else}}
{{    inherited InternalWrite(S, bWriteLine);}}
{{end;}}

 


> Make the class TGUIConsole thread-safe
> --------------------------------------
>
>                 Key: THRIFT-4468
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4468
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: Delphi - Library
>    Affects Versions: 0.11.0
>            Reporter: Anton Shchyrov
>            Assignee: Jens Geyer
>            Priority: Major
>             Fix For: 0.12.0
>
>
> In Delphi all methods that refer to VCL should do it only from main thread. But class TGUIConsole despite the name does not contain any synchronization methods.
> My suggestion is to rename this class to TStringsConsole, make method InternalWrite virtual and make new class TGUIConsole inherits from TStringsConsole
>  
> {code:java}
> TGUIConsole = class( TStringsConsole )
> protected
>    procedure InternalWrite(const S: string; bWriteLine: Boolean); override;
> end;
> { TGUIConsole }
> procedure TGUIConsole.InternalWrite(const S: string; bWriteLine: Boolean);
>  begin
>    if TThread.CurrentThread.ThreadID <> MainThreadID then begin
>      TThread.Synchronize(nil, procedure
>        begin
>          inherited InternalWrite(S, bWriteLine);
>        end
>      );
>    end else
>      inherited InternalWrite(S, bWriteLine);
>  end;
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)