Lazarus

Free Pascal => FPC development => Topic started by: Zaher on March 03, 2019, 07:27:15 pm

Title: [Thread] Future Request, Passing object parameter with Synchronizeor Queue
Post by: Zaher on March 03, 2019, 07:27:15 pm
According to this article (https://www.uweraabe.de/Blog/2011/01/30/synchronize-and-queue-with-parameters/?fbclid=IwAR1eVfV3GS76Mep4apthD0MZKE6RygEGTJY0iha_jP_AIuJNY1p6QxPotnY)

We need to use anonymous procedure to pass parameter to main thread, but while that not exists in FPC right now (not sure I tested FPC3.1.1)

Why not adding another param  to synchronize/queue with procedure pointer, another pointer/object, to pass it to the procedure when call it.

procedure MyProc(AObject: TObject);

in the thread
Synchronize(MyProc, MyObject);
Title: Re: [Thread] Future Request, Passing object parameter with Synchronizeor Queue
Post by: marcov on March 03, 2019, 07:50:03 pm
It would be delphi incompatible, and only complicate matters once anonymous methods is done.

I myself still use the same scheme I used during D7, a pool of objects and a queue, and then synchronize draining the queue.

The only change is that generics it is easier to instantiate them typesafe.
Title: Re: [Thread] Future Request, Passing object parameter with Synchronizeor Queue
Post by: Zaher on March 03, 2019, 08:29:09 pm
yes I know Delphi incompatible, but it will not break compatibility, FPC should have its own way, BTW yeah I don't think I will see this feature in my future :P .

I still using pool, queue too.
TinyPortal © 2005-2018