by user6294 » Thu Jun 18, 2020 11:29 am
Hi,
Thanks for that - I could quiet things to work without the code crashing in the destructor of one of our logging classes. But here's the issue I'm trying to
solve :
We have these (only relevant details included) classes
// (1) Helper Classes
class CookieGetter {
public:
CookieGetter(std::string cookieName, ...);
// . . .
// WIN32 event sync object created with ::CreateEvent() autoreset mode and initially not signaled
AutoResetEvent _finished;
// . . .
};
class Visitor : public CookieVisitora {
public:
Visitor(..., AutoResetEvent & finished,...);
~Visitor();
// keep a ref to _finished from CookieGetter
AutoResetEvent & _finished;
};
====
// (2) threading and visitor
In CookieGetter c'tor (called from CEF UI thread)
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager(NULL);
manager->VisitAllCookies(new Visitor(..., _finished, cookie_name, ...));
In Visitor d'tor (in 58.x is called from CEF IO thread)
Visitor::~Visitor() {
_finished.set(); // set to signaled and allow 1 block thread to run
}
Above classes are used like this :
In MFC message handler to get cookie value :
LRESULT SomeWindowsClass::OnGetCookieRequest(...) {
CookieGetter getter("MY_COOKIE",...);
// blocks on a ::WaitForSingleObject(..., INIFINITE);
// until ~Visitor() is called (on CEF IO thread)
getter.wait();
// at this point, in 58.x we would have the cookie value ready to be read
}
But in 79.x, the Visitor d'tor is now invoked on the CEF UI thread,
so I can't make the getter.wait() block on the event synch object because both the
waiting thread and the thread doing the releasing are the same UI thread now !
Really would appreciate some guidance on this.
Many Thanks again