[libcxx-commits] [PATCH] D145183: [libc++] Implement `stop_token`

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 17 05:28:54 PDT 2023


huixie90 added inline comments.


================
Comment at: libcxx/include/__stop_token/atomic_unique_lock.h:40
+  template <class _Pred>
+  _LIBCPP_HIDE_FROM_ABI __atomic_unique_lock(std::atomic<_State>& __state, _Pred&& __fail_to_lock) noexcept
+      : __state_(__state), __is_locked_(false) {
----------------
ldionne wrote:
> Would it make sense to use `std::try_to_lock_t` here to convey that we're taking the lock? Otherwise, this can be confusing with `std::unique_lock`.
`std::try_to_lock_t` is non-blocking. here we are still blocking so might not be appropriate


================
Comment at: libcxx/include/__stop_token/stop_callback.h:84
+        __state_() {
+    if (__state) {
+      if (__state->__add_callback(this)) {
----------------
ldionne wrote:
> Isn't this always `nullptr` since you default initialize it above?
`__state` is a function parameter which is not always `nullptr`
`__state_` is the member which is `nullptr`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145183/new/

https://reviews.llvm.org/D145183



More information about the libcxx-commits mailing list