[webkit-dev] Should we ever use std::function instead of WTF::Function?

Alex Christensen achristensen at apple.com
Tue Jun 13 12:37:49 PDT 2017


Ok, maybe we can get rid of std::function, then!  I hadn’t used BlockPtr as much as Chris.  I’d be opposed to adding a copy constructor to WTF::Function because the non-copyability of WTF::Function is why we made it, and it has prevented many bugs.

I’ve also seen many cases where I have a WTF::Function that I want to make sure is called once and only once before destruction.  I wouldn’t mind adding a WTF::Callback subclass that just asserts that it has been called once.  That would’ve prevented some bugs, too, but not every use of WTF::Function has such a requirement.

> On Jun 13, 2017, at 12:31 PM, Chris Dumez <cdumez at apple.com> wrote:
> 
> We already have BlockPtr for passing a Function as a lambda block.
> 
> Chris Dumez
> 
> On Jun 13, 2017, at 12:29 PM, Alex Christensen <achristensen at apple.com <mailto:achristensen at apple.com>> wrote:
> 
>> std::function, c++ lambda, and objc blocks are all interchangeable.  WTF::Functions cannot be used as objc blocks because the latter must be copyable.  Until that changes or we stop using objc, we cannot completely eliminate std::function from WebKit.
>> _______________________________________________
>> webkit-dev mailing list
>> webkit-dev at lists.webkit.org <mailto:webkit-dev at lists.webkit.org>
>> https://lists.webkit.org/mailman/listinfo/webkit-dev <https://lists.webkit.org/mailman/listinfo/webkit-dev>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20170613/0b92ecfa/attachment.html>


More information about the webkit-dev mailing list