Which thread/process am I in?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Which thread/process am I in?

Postby palaver » Sun Nov 29, 2015 8:26 am

I often read in the documentation or in the source code comments, something along the lines of "This function can only be called in the browser process" or "This must be invoked in the UI thread" (these quotes are not verbatim, but you get the idea). How do I know which thread or process I'm in? For example, I see code in the cefclient application that looks like this:
Code: Select all
if (CURRENTLY_ON_MAIN_THREAD()) {
    CreateRootWindow(settings);
} else {
    MAIN_POST_CLOSURE(
        base::Bind(&RootWindowWin::CreateRootWindow, this, settings));
}

Is writing such code sufficient for CEF to take care of this for me?
palaver
Techie
 
Posts: 36
Joined: Wed Nov 25, 2015 9:51 am

Re: Which thread/process am I in?

Postby magreenblatt » Mon Nov 30, 2015 2:21 pm

Take a look at include/cef_task.h. It exposes functions for determining the current thread and for posting tasks to specific threads. TID_RENDERER is the only thread in the renderer process -- all the rest are in the browser process.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 101 guests