<commit_before>#pragma once

namespace But
{
namespace Threading
{
namespace detail
{

template<typename T>
class LockProxy final
{
public:
  explicit LockProxy(T& t):
    t_{&t}
  {
    t_->lock();
  }
  ~LockProxy()
  {
    releaseIfOwned();
  }

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

  LockProxy(LockProxy&& other):
    t_{other.t_}
  {
    other.t_ = nullptr;
  }
  LockProxy& operator=(LockProxy&& other)
  {
    if( &other == this )
      return *this;
    releaseIfOwned();
    t_ = other.t_;
    other.t_ = nullptr;
    return *this;
  }

  T* operator->() { return t_; }

private:
  inline void releaseIfOwned()
  {
    if(not t_)
      return;
    t_->unlock();
    t_ = nullptr;
  }

  T* t_;
};

}
}
}
<commit_msg>added extra assertion for not-null pointer<commit_after>#pragma once
#include <But/assert.hpp>

namespace But
{
namespace Threading
{
namespace detail
{

template<typename T>
class LockProxy final
{
public:
  explicit LockProxy(T& t):
    t_{&t}
  {
    t_->lock();
  }
  ~LockProxy()
  {
    releaseIfOwned();
  }

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

  LockProxy(LockProxy&& other):
    t_{other.t_}
  {
    other.t_ = nullptr;
  }
  LockProxy& operator=(LockProxy&& other)
  {
    if( &other == this )
      return *this;
    releaseIfOwned();
    t_ = other.t_;
    other.t_ = nullptr;
    return *this;
  }

  T* operator->()
  {
    BUT_ASSERT(t_);
    return t_;
  }

private:
  inline void releaseIfOwned()
  {
    if(not t_)
      return;
    t_->unlock();
    t_ = nullptr;
  }

  T* t_;
};

}
}
}

{'fraction_non_alphanumeric': 0.14424832623250153, 'fraction_numerical': 0.0, 'mean_word_length': 2.7194570135746607, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1443300', 'n_tokens_mistral': 621, 'n_tokens_neox': 613, 'n_words': 136}