Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2020-09

TThread.RemoveQueuedEvents

10 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

Wath is in the following indented?

The doc says
https://www.freepascal.org/docs-html/rtl/classes/tthread.removequeuedevents.html

all calls to the given method .... are removed.

However there may be more than one way to read this.

aMethod: TThreadMethod
<https://www.freepascal.org/docs-html/rtl/classes/tthreadmethod.html> is "procedure of object"

The method "aMethod" (which is what is given) therefore consists of proc-address and instance-address.

However the code actually removes all methods at proc-address, regardless of the instance.

Does the "given method" mean:
1) "aMethod" as passed in as parameter, consisting of proc and instance
2) "method of the class" extracted from "aMethod"

Reply by email

Ondrej Pokorny
to Martin
Martin wrote 21 lines
Wath is in the following indented? The doc says https://www.freepascal.org/docs-html/rtl/classes/tthread.removequeuedevents.html > all calls to the given method .... are removed. However there may be more than one way to read this. aMethod: TThreadMethod <https://www.freepascal.org/docs-html/rtl/classes/tthreadmethod.html> is "procedure of object" The method "aMethod" (which is what is given) therefore consists of proc-address and instance-address. However the code actually removes all methods at proc-address, regardless of the instance. Does the "given method" mean: 1) "aMethod" as passed in as parameter, consisting of proc and instance 2) "method of the class" extracted from "aMethod"

It's a Delphi-compatibility method:
http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TThread.RemoveQueuedEvents

The Delphi docs are not much more help here but FPC should have the same behavior. Please check the Delphi behavior and clarify the docs.

Thanks, Ondrej

Reply by email

Martin Frb
to Ondrej Pokorny
Ondrej Pokorny wrote 13 lines
On 25.09.2020 03:30, Martin via fpc-devel wrote: > > Does the "given method" mean: > 1) "aMethod" as passed in as parameter, consisting of proc and instance > 2) "method of the class" extracted from "aMethod" It's a Delphi-compatibility method: http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TThread.RemoveQueuedEvents The Delphi docs are not much more help here but FPC should have the same behavior. Please check the Delphi behavior and clarify the docs.

Unfortunately I do not have Delphi.
Can anyone test this?

Reply by email

Pascal Riekenberg
to Martin Frb

Hi Martin,

there is a free Community Edition.

Pascal

Show quoted text 23 lines
Martin Frb via fpc-devel hat am 26.09.2020 13:35 geschrieben: On 25/09/2020 13:03, Ondrej Pokorny via fpc-devel wrote: > > On 25.09.2020 03:30, Martin via fpc-devel wrote: > > > > > Does the "given method" mean: > > 1) "aMethod" as passed in as parameter, consisting of proc and instance > > 2) "method of the class" extracted from "aMethod" > > > > > > > It's a Delphi-compatibility method: http://docwiki.embarcadero.com/Libraries/Sydney/en/System.Classes.TThread.RemoveQueuedEvents > > The Delphi docs are not much more help here but FPC should have the same behavior. Please check the Delphi behavior and clarify the docs. > > > > Unfortunately I do not have Delphi. Can anyone test this? _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Martin Frb
to Martin Frb: Unfortunately I do not have Delphi. Can anyone test this?
Martin Frb wrote
Unfortunately I do not have Delphi. Can anyone test this?

I made a test program

If it does not print any "in foo" then it ignores the instance. Otherwise it should print one "in foo".

Besides of "what Delphi does", what would anyone expect from reading the code?

program Project1;
{$mode objfpc}{$H+}
uses
   {$IFDEF UNIX}  cthreads,  {$ENDIF}  Classes;
type
   TMyClass = class
     procedure Foo;
   end;
   TMyThread = class(TThread)
   public
     procedure Execute; override;
   end;
var
   i: integer;
procedure TMyThread.Execute;
var
   c1, c2: TMyClass;
begin
   c1 := TMyClass.Create;
   c2 := TMyClass.Create;
   Queue(self, @c1.Foo);
   Queue(self, @c2.Foo);
   RemoveQueuedEvents(Self, @c1.Foo);
   inc(i);
end;
procedure TMyClass.Foo;
begin
   writeln('In Foo');
end;
begin
   i := 0;
   TMyThread.Create(False);
   while i = 0 do ;
   CheckSynchronize();
   writeln('Did we get one or none "In Foo"');
   ReadLn;
end.

Reply by email

Pascal Riekenberg
to Martin Frb

Yes,

you get no "In Foo"!

Pascal

Show quoted text 15 lines
Martin Frb via fpc-devel hat am 26.09.2020 14:05 geschrieben: On 26/09/2020 13:58, Pascal Riekenberg wrote: > > Hi Martin, > > there is a free Community Edition. > > > > Ok, but maybe someone who already has it installed, can copy and paste the test that I posted? (should barely take half a minute or less) _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Sven Barth
to Mattias Gaertner: On Sat, 26 Sep 2020 14:05:21 +0200 Delphi checks Code and Data. Mattias
Mattias Gaertner wrote 12 lines
On Sat, 26 Sep 2020 14:05:21 +0200 Martin Frb via fpc-devel wrote: > On 26/09/2020 13:58, Pascal Riekenberg wrote: >> Hi Martin, >> >> there is a free Community Edition. >> > Ok, but maybe someone who already has it installed, can copy and > paste the test that I posted? (should barely take half a minute or > less) Delphi checks Code and Data.

FPC now behaves the same in r47007.

Regards,
Sven

Reply by email