Feature #5649

Add an API to WIOService to cancel scheduled tasks

Added by Kayra Akman almost 6 years ago. Updated almost 6 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


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.


Updated by Wim Dumon almost 6 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


Also available in: Atom PDF