Project

General

Profile

Feature #5649

Add an API to WIOService to cancel scheduled tasks

Added by Kayra Akman over 5 years ago. Updated over 5 years ago.

Status:
New
Priority:
Normal
Target version:
-
Start date:
04/10/2017
Due date:
% Done:

0%

Estimated time:

Description

As mentioned in #5648, WIOService::stop() blocks until all tasks, running or scheduled to run, are executed. Since there is no API to cancel scheduled tasks, WServer::stop() may get blocked due to scheduled tasks. If a scheduled task is to be run after a long period of time, the application becomes useless since the server is stopped before the IO service is stopped in WServer::stop().

IMO, an API such as WIOService::cancelScheduledTasks() should be added to WIOService and called in WServer::stop() before stopping the IO service.

#1

Updated by Wim Dumon over 5 years ago

  • Assignee set to Roel Standaert

Hey Kayra,

That would probably be a useful addition.

We noted however that deadline_timers are not thread safe, so canceling them will need to be done with proper care in Wt's multithreaded architecture.

This splits the problem in two parts:

  • create timers so that they can be canceled (proper use of strands seem to allow for this); in that respect it's probably a good idea to have the schedule call return an object that allows cancelation
  • keep track of all active timers, so that cancelScheduledTasks() can be implemented

Wim.

Also available in: Atom PDF