#1 2021-10-05 20:35:19

leus
Member
Registered: 2012-09-05
Posts: 79

TimerEnable - does it run in parallel, or in a queue?

I've looked at the TimerEnable code but I'm not sure if I'm following - if a process takes some time, and the timer is short, what happens? Is the timer callback called immediately, or it is enqueued until the already running process finishes?

Thanks,

Offline

#2 2021-10-06 17:47:19

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

Re: TimerEnable - does it run in parallel, or in a queue?

There is a background thread, which wakes up every second and run all the tasks in the queue, in the given period of time.
So if a process takes a lot of time, it would be executed in this single thread, so other tasks in the queue will wait for their execution.
Therefore, it is not a good idea for a task to take more than a few dozen milliseconds - unless it is what you expect.
Note that you can create as many background thread as needed. This is one in each TSQLRest/TRest instance, but you can create others.

You can run a task immediately by setting the corresponding flag to "true" when you setup the task.

Offline

Board footer

Powered by FluxBB