Allowing abseil cleanup

378 views
Skip to first unread message

John Admanski

unread,
Nov 15, 2022, 5:30:53 PM11/15/22
to cxx
Currently the abseil cleanup library is on the TBD list for features. I would like to suggest that it should be allowed.

The library is quite small and fairly freestanding, not depending on much more than their core utility functions and macros. So there aren't any conflicts with depending on other parts of the library which are banned, or which interact poorly with the standard data structures and idioms of the chromium codebase.

The benefits to allowing it are not huge; anything you can do with it you can do by hand-rolling your own RAII objects. In practice, though, that ends up being not really worthwhile for one-offs where you want to ensure a cleanup/closing operation happens on all exits paths. So usually I just see the cleanup code pasted before every return; switching to using absl::Cleanup is an easier sell as an improvement, compared to asking for someone to add all the boilerplate needed for a custom functor.

-- John

Peter Kasting

unread,
Nov 15, 2022, 5:38:42 PM11/15/22
to John Admanski, cxx
+1 to allowing this. absl::Cleanup is a small but fairly monotonic nice-to-have IMO.

PK

Jan Wilken Dörrie

unread,
Nov 16, 2022, 2:58:47 AM11/16/22
to Peter Kasting, John Admanski, cxx
+1, this is a nice alternative to base::ScopedClosureRunner if a OnceClosure is not already handily available.

On Tue, Nov 15, 2022 at 11:38 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:
+1 to allowing this. absl::Cleanup is a small but fairly monotonic nice-to-have IMO.

PK

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFBPLRgbtrTt96OVnT3DciJrVhFyJSXWWHvDCmE0Y68wYg%40mail.gmail.com.

Daniel Cheng

unread,
Nov 16, 2022, 1:01:54 PM11/16/22
to Jan Wilken Dörrie, Peter Kasting, John Admanski, cxx
+1. I'd actually say we should use this in preference to ScopedClosureRunner if callbacks don't need to be involved.

Daniel

John Admanski

unread,
Nov 16, 2022, 2:01:50 PM11/16/22
to cxx, Daniel Cheng, pkas...@google.com, John Admanski, cxx, Jan Wilken Dörrie
There seems to be a fairly positive consensus, so I should send a code review to update the style guide.
Reply all
Reply to author
Forward
0 new messages