您当前的位置: 首页 >  c++

令狐掌门

暂无认证

  • 1浏览

    0关注

    513博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

C++ WebRTC基础(5) :webrtc c++ 线程异步调用介绍与代码演示

令狐掌门 发布时间:2021-09-29 00:24:07 ,浏览量:1

  在进行RTC应用开发时,会有加入频道,其它用户加入频道,房间的流发生变化等操作,对于这些行为,需要有相应的通知,发给界面层,需要进行异步处理,例如当有用户加入房间时,就触发对应的回调函数返回加入的结果,而这个结果是用户层被动获取的,因为不知道什么时候加入成功,通过常会有一个virtual方法让界面层override获取结果。   webrtc源码提供了线程异步调用的实现,代码在rtc_base/rtc_base, 如下所示: 在这里插入图片描述

webrtc的异步调用

在头文件async_invoker.h中有相关的说明: Invokes function objects (aka functors) asynchronously on a Thread, and owns the lifetime of calls (ie, when this object is destroyed, calls in flight are cancelled). AsyncInvoker can optionally execute a user-specified function when the asynchronous call is complete, or operates in fire-and-forget mode otherwise.

AsyncInvoker does not own the thread it calls functors on.

A note about async calls and object lifetimes: users should be mindful of object

关注
打赏
1652240117
查看更多评论
立即登录/注册

微信扫码登录

0.0503s