schedsvc: Add support for running missed tasks at the service start.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Dmitry Timoshkov 2018-06-08 15:43:55 +08:00 committed by Alexandre Julliard
parent ae79454989
commit 8d540ec7cf
3 changed files with 26 additions and 0 deletions

View File

@ -1039,6 +1039,30 @@ void check_task_time(void)
LeaveCriticalSection(&at_job_list_section);
}
void check_missed_task_time(void)
{
FILETIME current_ft, last_ft;
struct job_t *job;
GetSystemTimeAsFileTime(&current_ft);
FileTimeToLocalFileTime(&current_ft, &current_ft);
EnterCriticalSection(&at_job_list_section);
LIST_FOR_EACH_ENTRY(job, &at_job_list, struct job_t, entry)
{
if (SystemTimeToFileTime(&job->data.last_runtime, &last_ft))
{
if (job_runs_at(job, &last_ft, &current_ft))
{
run_job(job);
}
}
}
LeaveCriticalSection(&at_job_list_section);
}
void remove_job(const WCHAR *name)
{
struct job_t *job;

View File

@ -31,6 +31,7 @@ void update_process_status(DWORD pid) DECLSPEC_HIDDEN;
BOOL get_next_runtime(LARGE_INTEGER *rt) DECLSPEC_HIDDEN;
void check_task_time(void) DECLSPEC_HIDDEN;
void load_at_tasks(void) DECLSPEC_HIDDEN;
void check_missed_task_time(void) DECLSPEC_HIDDEN;
static inline WCHAR *heap_strdupW(const WCHAR *src)
{

View File

@ -54,6 +54,7 @@ static DWORD WINAPI tasks_monitor_thread(void *arg)
TRACE("Starting...\n");
load_at_tasks();
check_missed_task_time();
htimer = CreateWaitableTimerW(NULL, FALSE, NULL);
if (htimer == NULL)