Francisco Tolmasky
unread,Mar 29, 2024, 12:15:18 PM3/29/24Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to platform-architecture-dev
I am trying to wrap my head around the variety of different Thread classes in Blink and how they relate to each-other (base::Thread, base::SimpleThread, blink::Thread, blink::MainThread, blink::NonMainThread, blink::RenderThread, and Impl varieties of those sometimes). If there is a good summary of this somewhere -- I'd love to a link, I did some searching but couldn't find anything around this specific topic (the "Threading and Tasks in Chrome" documentation refers to Threads mainly in the abstract, not diving into the specific classes, or when you should use beach one). As far as I've gathered, I think the distinctions seem to arrise from:
1. "Descriptive" vs. "Prescriptive" threads. Namely, I would describe the "MainThread" classes as being "descriptive", in that they aren't used to actually *start* any new threads, but rather to create a representation of an existing thread that you are on. On the other hand, most (all?) other thread classes appear to be "prescriptive," or put another way, you can actually start a thread with them.
2. The (apparent) significant overlap arrises from each subsequent layer in the stack wanting their own more "specialized" representation of a thread. At the very bottom, base::Thread has no knowledge of web stuff at all, and as you climb up, each layer has a more sophisticated description of a Thread's purpose.
Is this more or less it? There is no "canonical" main thread object, whoever happens to care about that sort of thing in isolated enough components of base/blink/chrome just takes it upon themselves to manually identify the main thread and store a (unique) pointer to their custom representation of it?
The reason I ask is that I am wanting to run Blink in a background thread, I believe the same way content_shell does in single-process mode, but I was fairly confused about InProcessRenderThread existing simultaneously to RenderThreadImpl existing simultaneously to MainThread, etc, and I am just scared that there might be some delicate subtlety to this that I should look out for.
Thanks!
Francisco