| Summary: | WTF::Function adoption should be explicit instead of implicit | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Geoffrey Garen <ggaren> | ||||||||
| Component: | New Bugs | Assignee: | Geoffrey Garen <ggaren> | ||||||||
| Status: | RESOLVED FIXED | ||||||||||
| Severity: | Normal | CC: | benjamin, cdumez, cmarcelo, darin, ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer | ||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||
| Version: | WebKit Nightly Build | ||||||||||
| Hardware: | Unspecified | ||||||||||
| OS: | Unspecified | ||||||||||
| Attachments: |
|
||||||||||
|
Description
Geoffrey Garen
2020-07-22 14:15:49 PDT
Created attachment 404961 [details]
Patch
If someone can figure out the template fu to automatically deduce the function type in adoptImpl, that would be great! Comment on attachment 404961 [details]
Patch
Does it really need to be name adoptImpl and not just adopt? Are there name conflicts?
I don't think there are name conflicts. Would you rename leakImpl() to leak() too? I am increasingly unsure about this. Why should WTF::Function adoption be explicit? In other cases, we do that because we are concerned about object lifetime. Like a raw pointer being adopted by a std::unique_ptr. Does that apply here. I don’t think "impl" is the correct term for a C++ function. Yes, this is all about the lifetime of the unique_ptr that holds the functor. leakImpl() leaks the unique_ptr and adopt takes ownership of the pointer. Created attachment 404971 [details]
Patch
Comment on attachment 404971 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=404971&action=review > Source/WTF/wtf/Function.h:125 > +template <typename T> inline Function<T> adopt(typename Function<T>::Impl* impl) I think you want to write something more like this: template<typename Out, typename... In> Function<Out(In...)> adopt(Detail::CallableWrapperBase<Out, In...>* pointer) That should allow you to use adopt() without template arguments. Created attachment 404992 [details]
Patch for landing
Committed r264743: <https://trac.webkit.org/changeset/264743> All reviewed patches have been landed. Closing bug and clearing flags on attachment 404992 [details]. |