Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::stop_callback<Callback>::~stop_callback

      From cppreference.com
      <cpp‎ |thread‎ |stop callback
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      Condition variables
      (C++11)
      Semaphores
      Latches and Barriers
      (C++20)
      (C++20)
      Futures
      (C++11)
      (C++11)
      (C++11)
      Safe reclamation
      Hazard pointers
      Atomic types
      (C++11)
      (C++20)
      Initialization of atomic types
      (C++11)(deprecated in C++20)
      (C++11)(deprecated in C++20)
      Memory ordering
      (C++11)(deprecated in C++26)
      Free functions for atomic operations
      Free functions for atomic flags
       
       
      ~stop_callback();
      (since C++20)

      Destroys thestop_callback object.

      If*this has astop_token with associated stop-state, deregisters the callback from it.

      If the callback function is being invoked concurrently on another thread, the destructor does not complete until the callback function invocation is complete. If the callback function is being invoked on the same thread the destructor is being invoked on, then the destructor returns without waiting for callback invocation to complete (see Notes).

      [edit]Notes

      Thestop_callback destructor is designed to prevent race conditions and deadlocks. If another thread is currently invoking the callback, then the destructor cannot return until that completes, or else the function object could potentially be destroyed while it is being executed. The callback function is not required to be neither copyable nor movable - it lives in thestop_callback object itself even after registration.

      On the other hand, if the current thread invoking the destructor is the same thread that is invoking the callback, then the destructor cannot wait or else a deadlock would occur. It is possible and valid for the same thread to be destroying thestop_callback while it is invoking its callback function, because the callback function might itself destroy thestop_callback, directly or indirectly.

      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/stop_callback/%7Estop_callback&oldid=161247"

      [8]ページ先頭

      ©2009-2025 Movatter.jp