github-actions[bot] commented on code in PR #39470:
URL: https://github.com/apache/doris/pull/39470#discussion_r1720099391
##########
be/src/util/once.h:
##########
@@ -42,95 +48,67 @@ namespace doris {
// }
//
// bool is_inited() const {
-// return _init_once.has_called() && _init_once.stored_result().ok();
+// return _init_once.is_called() && _init_once.stored_result().ok();
// }
// private:
// Status _do_init() { /* init logic here */ }
// DorisCallOnce<Status> _init_once;
// };
-template <typename ReturnType>
+
+template <typename R>
class DorisCallOnce {
public:
- DorisCallOnce() : _has_called(false) {}
-
- // this method is not exception safe, it will core when exception occurs in
- // callback method. I have tested the code
https://en.cppreference.com/w/cpp/thread/call_once.
- // If the underlying `once_flag` has yet to be invoked, invokes the
provided
- // lambda and stores its return value. Otherwise, returns the stored
Status.
- // template <typename Fn>
- // ReturnType call(Fn fn) {
- // std::call_once(_once_flag, [this, fn] {
- // _status = fn();
- // _has_called.store(true, std::memory_order_release);
- // });
- // return _status;
- // }
+ DorisCallOnce() : _eptr(nullptr), _is_exception_thrown(false),
_ret_val(std::nullopt) {}
Review Comment:
warning: use '= default' to define a trivial default constructor
[modernize-use-equals-default]
```suggestion
DorisCallOnce() : _eptr(nullptr), _is_exception_thrown(false),
_ret_val(std::nullopt) = default;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]