Sequential execution on the main/UI thread

332 views
Skip to first unread message

Vignesh Shenvi

unread,
Mar 2, 2023, 7:46:48 PM3/2/23
to schedu...@chromium.org
Hello:

We have two components that will be manipulating (inexpensive) and persisting data to the user pref store, and we would like sequential execution of these tasks in the UI thread to avoid races when it comes to data overwrites. From my understanding, these should *ideally* run sequentially as long as they run on the UI thread (given it's single threaded nature?), but the docs make it seem like there is an additional dimension that decides which task runner is used if we were to post an async task i.e the task traits. Can someone please confirm if this happens to be true, and maybe throw some light on what runner is used by default?

Thanks,
Vignesh

Vignesh Shenvi

unread,
Mar 6, 2023, 3:37:23 PM3/6/23
to Joe Mason, schedu...@chromium.org
Awesome! Thanks for the clarification, Jason. That makes more sense now. :)

On Mon, Mar 6, 2023 at 12:34 PM Joe Mason <joenot...@google.com> wrote:
2 tasks on the UI thread will definitely NOT run concurrently. What the TaskTraits can do is reorder the tasks that haven't started running yet, to put higher-priority tasks first.

As long as your 2 tasks use the same TaskTraits, the one that's posted 2nd will run after the one that's posted 1st. 



--
You received this message because you are subscribed to the Google Groups "scheduler-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scheduler-de...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/scheduler-dev/CAMYhthPMpeWK_HTHzraZaCY1v-toxTtTTsZXVNpWqAvYM-di6g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages