Home / Class/ RegistrationHandleRAII Class — pytorch Architecture

RegistrationHandleRAII Class — pytorch Architecture

Architecture documentation for the RegistrationHandleRAII class in RegistrationHandleRAII.h from the pytorch codebase.

Entity Profile

Source Code

aten/src/ATen/core/dispatch/RegistrationHandleRAII.h lines 7–34

class RegistrationHandleRAII final {
 public:
  explicit RegistrationHandleRAII(std::function<void()> onDestruction)
      : onDestruction_(std::move(onDestruction)) {}

  ~RegistrationHandleRAII() {
    if (onDestruction_) {
      onDestruction_();
    }
  }

  RegistrationHandleRAII(const RegistrationHandleRAII&) = delete;
  RegistrationHandleRAII& operator=(const RegistrationHandleRAII&) = delete;

  RegistrationHandleRAII(RegistrationHandleRAII&& rhs) noexcept
      : onDestruction_(std::move(rhs.onDestruction_)) {
    rhs.onDestruction_ = nullptr;
  }

  RegistrationHandleRAII& operator=(RegistrationHandleRAII&& rhs) noexcept {
    onDestruction_ = std::move(rhs.onDestruction_);
    rhs.onDestruction_ = nullptr;
    return *this;
  }

 private:
  std::function<void()> onDestruction_;
};

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free