#1 2016-05-18 06:23:28

hnb
Member
Registered: 2015-06-15
Posts: 290

Best way to free/manage threads

Sometimes I need to create new threads inside rest server methods to perform some actions. For example I'd like to return as soon as possible, so part of work can be redirected to separated thread. Additional thread isn't executed always. I wonder, maybe there is some nice technique in mormot to auto free the threads? I'd like to perform auto free when thread "Execute" was ended.

At the moment I have for that purpose my own structures.


best regards,
Maciej Izak

Offline

#2 2016-05-18 08:14:03

oz
Member
Registered: 2015-09-02
Posts: 98

Re: Best way to free/manage threads

Hi,
this behaviour is alteady implemented in:

TThread.FreeOnTerminate:=true;

Offline

#3 2016-05-18 08:23:09

hnb
Member
Registered: 2015-06-15
Posts: 290

Re: Best way to free/manage threads

that won't work for console/service application (eventually "Classes.CheckSynchronize" call is needed but I like to avoid that)


best regards,
Maciej Izak

Offline

#4 2016-05-18 11:58:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,666
Website

Re: Best way to free/manage threads

Check the TSynBackgroundThread* classes in SynCommons.pas.
You have several ways of implementing it in mORMot.

Those classes are used by low-level execution threading abilities of the framework.

Offline

Board footer

Powered by FluxBB