U++: Issueshttps://www.ultimatepp.org/redmine/https://www.ultimatepp.org/redmine/redmine/favicon.ico2013-09-18T17:49:08ZRedmine
Redmine Feature #523 (Patch ready): Periodic background jobs in skylarkhttps://www.ultimatepp.org/redmine/issues/5232013-09-18T17:49:08ZJan DolinĂ¡rdolik.rce@gmail.com
<p>Sometimes it is handy to be able to execute some periodic job inside the server that runs in background, independently from request handling threads. Probably most common example of this would be expiration of temporary data (either on disk or in database). Currently, it is not easy to do such thing in Skylark, as you can only react when a request comes and there is no guarantee when or if a request occurs. Also doing this correctly in thread is troublesome as SkylarkApp::quit is private, so it is not simple to quit the thread when the application is terminated.</p>
<p>So I wrote a patch that adds AddJob(Callback cb, int period=60) function to the public interface of SkylarkApp. This function can be used to add multiple jobs that will be executed with given periodicity (in seconds) in a background thread. The timing is not guaranteed to be precise and is only approximate, as longer job can postpone other jobs. If there are no jobs added, the extra thread is not created.</p>
<p>Example of usage:<br /><pre>
struct MyApp : SkylarkApp {
MyApp() {
root = "myapp";
}
};
void job1() {
LOG("JOB1 "<<GetSysTime());
}
void job2() {
LOG("JOB2 "<<GetSysTime());
}
CONSOLE_APP_MAIN
{
MyApp()
.AddJob(callback(job1),3)
.AddJob(callback(job2),5)
.Run();
}
</pre></p>
<p>What do you think Mirek, do you mind if I commit it? I'll of course add proper documentation if you say it is ok.</p>
<p>I think this might be even used internally to periodically expire the sessions. I think the way it is done now (on every 1000th request per thread, if I remember correctly), can lead to piling up way too many sessions in database, which in turn caused deadlocks in database on delete statements for me.</p> Feature #247 (In Progress): Use shared bz2, jpeg, tiff in linuxhttps://www.ultimatepp.org/redmine/issues/2472012-01-30T12:55:44ZMiroslav Fidlercxl@ntllib.org