Some tasks are better performed in the background than in a request-response cycle. Depending on the type of work, you can use a fiber-based task or thread.
A function or method that returns
void can be started as a fiber-based task with the
runTask() function. The parameters are the delegates (use
std.functional.toDelegate() if you have a function) and possible parameters.
Do not forget to be cooperative in your fiber: call a pseudo-blocking function or
yield() from time to time.
You can use such a background task to collect data about the server. With the next example, you can read the
/proc/loadavg file on Linux and collect the data of the last 10 minutes. On a request from a client, you ...