Le 26/07/14 20:29, Ian Forbes a écrit :
The approach I have in mind for this library respect to scheduled work of the N3785 proposal is quite different. Instead of adding the scheduled operations to a specific scheduled_executor polymorphic interface, I opted by adding two member template functions to a class scheduled_executor that wraps an existing executor. This scheduled_executor will probably have a thread to take of the time scheduled operations, but this is not necessary. The semantic of the time scheduled operations is a little bit different. The task will be submitted to the associated executor at/after the given time_point/duration. This describes the scheduling_adaptor class. Since there are no virtual methods the addition of template functions is possible. Right.
Note that your base class scheduled_executor is not an executor at all. Perhaps I should move this into detail then. I could also change the name to scheduled_executor_base and perhaps then change scheduling_adaptor to scheduled_executor.
This however would rule out any possible use of the scheduled_executor class a polymorphic base class since it would be hidden in detail. It seems that there is consensus on replacing the polymorphic approach by a type-erased approach. See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4032.html.
Anyway if you want to provide a dynamic polymorphic class and an adaptor, you could use scheduled_executor, scheduled_executor_adaptor for the dynamic polymorphic classes. If you take in account my design, the class could be named scheduled_executor_wrapper.
This has several advantages: * The time scheduled operations are available for all the executors. This is provided via the scheduling_adaptor class.
This is not correct, as your schedulling_adaptor needs an executor that has a timed queue. With my design, only the scheduled_executor would need a timed_queue.
* The template functions could accept any chrono::steady_clock::time_point or any chrono::duration. I can add template functions to do this. Others have requested this.
* The non-time scheduled task don't pay for the additional cost to manage with a priority queue. I can override (non-virtually) the submit(work) function in scheduling_adaptor to do this.
See above. This doesn't change anything, as the queue is a timed queue and so you will pay for the non-timed operations.
Vicente