当前位置: 首页 > news >正文

Cef笔记:Cef消息循环的集成

1. cef文档原文

https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage

Message Loop Integration
CEF can also integrate with an existing application message loop instead of running its own message loop. There are two ways to do this.

Call CefDoMessageLoopWork() on a regular basis instead of calling CefRunMessageLoop(). Each call to CefDoMessageLoopWork() will perform a single iteration of the CEF message loop. Caution should be used with this approach. Calling the method too infrequently will starve the CEF message loop and negatively impact browser performance. Calling the method too frequently will negatively impact CPU usage. See CefBrowserProcessHandler::OnScheduleMessagePumpWork for advanced usage details. You can test this mode in cefclient by running with the “–external-message-pump” command-line flag.
Set CefSettings.multi_threaded_message_loop = true (Windows and Linux only). This will cause CEF to run the browser UI thread on a separate thread from the main application thread. With this approach neither CefDoMessageLoopWork() nor CefRunMessageLoop() need to be called. CefInitialize() and CefShutdown() should still be called on the main application thread. You will need to provide your own mechanism for communicating with the main application thread (see for example the message window usage in cefclient_win.cpp). You can test this mode in cefclient on Windows or Linux by running with the “–multi-threaded-message-loop” command-line flag.

2. 译文

CEF 还可以与现有应用程序的消息循环集成,而非运行自身的消息循环。实现这一目标有两种方式:

定期调用 CefDoMessageLoopWork() 替代 CefRunMessageLoop()
每次调用 CefDoMessageLoopWork() 会执行一次 CEF 消息循环的单次迭代。使用此方法时需谨慎:调用频率过低会导致 CEF 消息循环“饥饿”,进而降低浏览器性能;调用频率过高则会增加 CPU 占用。高级用法详见 CefBrowserProcessHandler::OnScheduleMessagePumpWork。
在 cefclient 中,可通过命令行参数 --external-message-pump 测试此模式。

设置 CefSettings.multi_threaded_message_loop = true(仅限 Windows 和 Linux)
此设置会使 CEF 在独立于主应用程序线程的线程中运行浏览器 UI 线程。采用此方式时,无需调用 CefDoMessageLoopWork() 或 CefRunMessageLoop(),但仍需在主应用程序线程中调用 CefInitialize() 和 CefShutdown()。
您需要自行实现与主应用程序线程通信的机制(例如,可参考 cefclient_win.cpp 中消息窗口的使用方式)。在 Windows 或 Linux 的 cefclient 中,可通过命令行参数 --multi-threaded-message-loop 测试此模式。

http://www.dtcms.com/a/512303.html

相关文章:

  • 第十六篇:Lambda表达式:匿名函数对象的艺术
  • 织梦cms通用蓝白简介大气企业网站环保科技公司源码汕头网站制作全过程
  • xss-labs pass-06
  • 解决selenium提示chrome版本过低问题
  • 重庆做网站电话深圳做装修网站费用多少
  • 做网站的免费空间商品房交易网
  • 鸡蛋质量识别数据集,可识别染血的鸡蛋,棕色鸡蛋,钙沉积鸡蛋,污垢染色的鸡蛋,白鸡蛋,平均正确识别率可达89%,支持yolo, json, xml格式的标注
  • YOLOv4简单基础学习
  • 网站的域名每年都要续费南通网络科技有限公司
  • LLAMA-Factory Qwen3-1.7b模型微调
  • PageHelper 分页框架查询总数 SQL 错误解决方案:从源码逻辑到版本影响(含实验验证)
  • NExF——建立3D空间上的曝光场辅助重建
  • 网站建设公司 合肥影视后期制作培训机构全国排名
  • 审计 jenkins获取构建历史,生成excel
  • 【能源与流程工业案例】KBC借助TeeChart 打造工业级数据可视化平台
  • 网站站点的建立wordpress 清单 主题
  • 苏州市建设交易中心网站wordpress 插件 重置密码
  • Linux 网络协议栈数据流跟踪-静态路由demo
  • 【C++】STL容器--list的模拟实现
  • 再次使用xca软件生成自签证书的补充说明
  • 第2章 数据库系统的核心--数据模型
  • 计算机组成基础
  • 迅投xtquant获取股票对应的申万行业
  • 百度seo网站在线诊断小程序开发平台需要网站吗
  • 网站开发用什么书什么网站可以做行测
  • 柳州做网站公司网站建设实施方案
  • excel拆分和合并代码的思路整合和工具打包
  • 信刻——安全生产音视频录音录像自动刻录备份归档管理系统
  • 外贸购物网站开发厦门seo推广外包
  • 公司企业网站设计尺寸discuz 同步wordpress