首页 > cef > CEF-CefPostTask简介
2017九月4

CEF-CefPostTask简介

有几种方式

#include "include/cef_runnable.h"

CefPostTask(TID_UI, NewCefRunnableMethod(this,&DUINativeWeb::OpenUrl,pszURL,iFlags,pszTargetFrameName,pszHeaders,pszPostData,iPostDataLen));

或者

#include "include/base/cef_bind.h"

#include "include/base/cef_bind_helpers.h"

#include "wrapper/cef_closure_task.h"

CefPostTask(TID_UI, base::Bind(base::IgnoreResult(&DUINativeWeb::OpenUrl),this,pszURL,iFlags,pszTargetFrameName,pszHeaders,pszPostData,iPostDataLen));

或者自己重载task

官方的解释总是最权威,有疑问看这里或者直接看代码中的说明: bind_helpers.h. 

传值方式 描述
this 或 对象指针

如果对象本身是一个RefCountedThreadSafe, 没有问题.

如果是个裸指针,应当尽量避免,除非你可以保证它的线程安全.

base::Unretained

注意:使用这个的前提是有其它同步机制保障对象的生命周期.

  1. 如果有其它同步机制保障对象的生命周期,可以使用Unretained()传递非引用计数的对象.

  2. 如果是一个非引用计数的对象,可以使用Unretained()封装起来.

base::Owned

如果是临时对象,或者担心任务执行完成后对象可能出现泄露,可以使用Owned, 表示由Task

持有对象的所有权,在结束时析构它.

base::Passed 如果要执行Task需要传入scoped指针,就可以使用它转换,它也可以避免拷贝,而是类似move语义.
base::ConstRef 类似常量引用,不希望bind过程出现拷贝,就可以使用它.
base::IgnoreResult 如果Task要调用的方法带有返回值,而你又不关心返回值就可以使用IgnoreResult来传入对象指针.

 

文章作者:hgy413
本文地址:http://hgy413.com/4249.html
版权所有 © 转载时必须以链接形式注明作者和原始出处!

16 Responses to “CEF-CefPostTask简介”

  1. #1 minecraft 回复 | 引用 Post:2018-10-04 20:02

    I know this web page presents quality dependent posts and extra information, is there any other website
    which presents such things in quality?

  2. #2 minecraft 回复 | 引用 Post:2018-10-07 16:09

    Hello, i read your blog occasionally and i own a similar one and i was just wondering if you get a lot of spam comments?
    If so how do you reduce it, any plugin or anything
    you can recommend? I get so much lately it’s driving me mad so any support is very much appreciated.

  3. Excellent blog you have here but I was wanting to know if you knew
    of any user discussion forums that cover the same topics discussed here?
    I’d really like to be a part of online community where
    I can get responses from other knowledgeable individuals that share the same interest.

    If you have any recommendations, please let me know.
    Appreciate it!

  4. I am regular visitor, how are you everybody? This post
    posted at this web page is in fact fastidious.

  5. Hello it’s me, I am also visiting this web page on a regular basis,
    this web site is really pleasant and the people are really sharing nice thoughts.

  6. #6 tinder dating site 回复 | 引用 Post:2018-10-17 12:23

    When someone writes an post he/she keeps the thought of a user in his/her brain that how a user can know it.
    Therefore that’s why this article is great. Thanks!

  7. #7 Coconut Oil Benefits 回复 | 引用 Post:2018-10-21 08:21

    Great beat ! I would like to apprentice while you amend
    your website, how can i subscribe for a blog website?
    The account helped me a appropriate deal. I had been a little bit familiar of this your broadcast offered shiny clear concept

  8. #8 Coconut Oil 回复 | 引用 Post:2018-10-24 17:22

    I am sure this post has touched all the internet visitors, its really really good paragraph on building up
    new webpage.

  9. #9 quest bars cheap 回复 | 引用 Post:2018-11-03 16:24

    Its not my first time to go to see this web page, i am browsing this web page dailly and
    get good information from here daily.

  10. #10 quest bars 回复 | 引用 Post:2018-11-05 01:55

    Awesome article.

  11. #11 Quest Bars Cheap 回复 | 引用 Post:2018-11-07 01:03

    Hey I know this is off topic but I was wondering if you knew of any widgets I could add to
    my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite
    some time and was hoping maybe you would have some experience with something like this.

    Please let me know if you run into anything. I truly enjoy reading your
    blog and I look forward to your new updates.

  12. #12 Sling TV 回复 | 引用 Post:2018-11-14 14:20

    I have been exploring for a little for any high quality
    articles or weblog posts on this sort of house .
    Exploring in Yahoo I ultimately stumbled upon this web site.
    Reading this info So i’m glad to express that I have a very just right uncanny feeling I came upon exactly what I
    needed. I such a lot no doubt will make certain to do not overlook
    this site and give it a glance regularly.

  13. I think the admin of this website is actually working
    hard in support of his website, as here every data is quality based material.

  14. Hey I am so excited I found your weblog, I really found you by mistake,
    while I was searching on Askjeeve for something
    else, Anyhow I am here now and would just like to say thank you for
    a incredible post and a all round enjoyable blog (I also love the theme/design),
    I don’t have time to go through it all at the minute but I have saved it and also added your RSS feeds, so when I have time I will be back to read a great deal more,
    Please do keep up the awesome work.

  15. #15 descargar facebook 回复 | 引用 Post:2018-11-21 07:23

    Hi there, You’ve done a great job. I will definitely digg it and personally recommend to
    my friends. I am confident they will be benefited from this website.

  16. #16 descargar facebook 回复 | 引用 Post:2018-12-06 05:48

    Great article, exactly what I wanted to find.

发表评论