PSA: TaskQueueBase PostTask semantics change

122 views
Skip to first unread message

Markus Handell

unread,
Dec 19, 2022, 9:49:15 AM12/19/22
to discuss...@googlegroups.com

Hi all WebRTC users,


TL;DR

We are changing the current TaskQueueBase::PostTask semantics with respect to deleted tasks in the Chromium M111 release. Should your project override task queue implementations, the implementations may need adjustment after this change.


Why are we doing this?

Analysis has shown that stricter requirements around object destruction on task queues helps with async programming design. Specifically it helps with avoiding & removing blocking patterns.


Details:

With this change, destruction of posted tasks is guaranteed with TaskQueueBase::Current() pointing to the task queue posted to. Previously there was no such guarantee. The new documentation for PostTask reads:


As long as tasks are not posted from task destruction, posted tasks are guaranteed to be destroyed with Current() pointing to the task queue they were posted to, whether they're executed or not. That means SequenceChecker works during task destruction, a fact that can be used to guarantee thread-compatible object deletion happening on a particular task queue which can simplify class design. Note that this guarantee does not apply to delayed tasks.


All WebRTC and Chromium task queues have already been updated to support the new semantics, but third party task queue overrides may need updates to work correctly with WebRTC code.


To ensure a task queue implementation works with the new semantic, simply make it pass green through TaskQueueTest as specified in the task_queue_test.h docs.


Reply all
Reply to author
Forward
0 new messages