On 12 August 2016 at 10:20, Kentaro Hara <har...@chromium.org> wrote:HiCurrently we have multiple APIs to create cancellable tasks. We have inconsistently mixed CancellableTaskFactory and Timer. We recently introduced makeCancellable. It would be important to reach consensus about the design/APIs to move more things to the per-frame scheduler.A good start point would be to identify issues of CancellableTaskFactory and figure out how to make it better (so that we can use CancellableTaskFactory in common cases). As far as I chatted with tzik@ and hiroshige@, we see the following issues in CancellableTaskFactory:a) CancellableTaskFactory::create() cannot take function parameters. Hence, the caller site needs to store all parameters on |this| object before creating a task. This is not nice.b) CancellableTaskFactory doesn't guarantee one-shot-ness of the underlying WTF::Closure (i.e., the WTF::Closure can be posted multiple times). If one-shot-ness is not guaranteed, we need to keep alive the function parameters while CancellableTaskFactory is alive. This can unnecessarily extend the lifetime of the function parameters. Ideally we want to clear/std::move the parameters when the WTF::Closure is fired. Also, not having the one-shot-ness makes it hard to support cancellable tasks in task queues.c) CancellableTaskFactory should return a WTF::Closure instead of a Task so that we can always pass in WTF::Closure to postTask APIs.Yes it should return a WTF::Closure and I think we should try to get rid of WebTaskRunner::Task.Also I'm planning on introducing a new API to WebTaskRunner:TaskHandle postCancellableTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>);DelayedTaskHandle postDelayedTask(const WebTraceLocation&, std::unique_ptr<WTF::Closure>, double delayMs);// Will remove the task from the queuebool CancelTask(TaskHandle);bool CancelTask(DelayedTaskHandle);
It might make sense to add something similar to CancellableTaskFactory which holds the TaskHandle/DelayedTaskHandle or even replace CancellableTaskFactory entirely.
Are there any other issues you're aware of?a) and c) would be easy to fix but I'm not sure about b).--Kentaro Hara, Tokyo, Japan
> bool CancelTask(TaskHandle);Can we cancel a task only by TaskHandle?If we need a pointer to WebTaskRunner to use CancelTask(), we might have to retain a reference to a TaskRunner because TaskRunnerHelper::get() might return different TaskRunners when called for postCancellableTask() and when called for CancelTask().
--
You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architecture-dev+unsubsc...@chromium.org.
To post to this group, send email to platform-architecture-dev@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CABg10jzppS1Q%3D809bxyURFT5kUDFnGC0taGh16EhBXGzt-e6Sg%40mail.gmail.com.
Are y'all aware of base::CancelableCallback? It provides cancelable tasks without requiring any extra post-task APIs. I'm not sure if something like that won't work or has other downsides for you, but want to make sure you've seen it.
On Fri, Aug 12, 2016 at 2:20 AM, Kentaro Hara <har...@chromium.org> wrote:
HiCurrently we have multiple APIs to create cancellable tasks. We have inconsistently mixed CancellableTaskFactory and Timer. We recently introduced makeCancellable. It would be important to reach consensus about the design/APIs to move more things to the per-frame scheduler.A good start point would be to identify issues of CancellableTaskFactory and figure out how to make it better (so that we can use CancellableTaskFactory in common cases). As far as I chatted with tzik@ and hiroshige@, we see the following issues in CancellableTaskFactory:a) CancellableTaskFactory::create() cannot take function parameters. Hence, the caller site needs to store all parameters on |this| object before creating a task. This is not nice.b) CancellableTaskFactory doesn't guarantee one-shot-ness of the underlying WTF::Closure (i.e., the WTF::Closure can be posted multiple times). If one-shot-ness is not guaranteed, we need to keep alive the function parameters while CancellableTaskFactory is alive. This can unnecessarily extend the lifetime of the function parameters. Ideally we want to clear/std::move the parameters when the WTF::Closure is fired. Also, not having the one-shot-ness makes it hard to support cancellable tasks in task queues.c) CancellableTaskFactory should return a WTF::Closure instead of a Task so that we can always pass in WTF::Closure to postTask APIs.Are there any other issues you're aware of?a) and c) would be easy to fix but I'm not sure about b).--Kentaro Hara, Tokyo, Japan
--
You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architect...@chromium.org.
To post to this group, send email to platform-arc...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CABg10jzppS1Q%3D809bxyURFT5kUDFnGC0taGh16EhBXGzt-e6Sg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architect...@chromium.org.
To post to this group, send email to platform-arc...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CAHtyhaSX8p0gXMjAf1ULzrcXij%3DEPDtzaH9t%2BrVGKQYUi39XVg%40mail.gmail.com.