I post 10 task that call CefV8Value to TID_RENDERER thread on other thread. But only 4 or 6 "promise.then(callback)" is invoked.
The resolve is invoked then c++ call CefV8Value, but cannot set Promise state to resolved and it's not invoke promise.then(cb).
It's my promise wrap function.
- Code: Select all
return new Promise(function(args, resolve, reject)
{
args.push(function(err)
{
if(err)
reject(err);
else
{
if(arguments.length > 1)
resolve(arguments[1]);
else
resolve();
}
});
this.func.apply(this, args);
}.bind(this, args));
It's c++ code. ZefPostTask is function post a CefTask to call std::function<void()>.
- Code: Select all
ZefPostTask(TID_RENDERER, [context, callback, base64Str]()
{
if (!context->IsValid() || !context->Enter())
return;
callback->ExecuteFunction(nullptr, { CefV8Value::CreateNull(), CefV8Value::CreateString(base64Str.data()) });
context->Exit();
});