<commit_before>#ifndef MIMOSA_SHARED_MUTEX_HH
# define MIMOSA_SHARED_MUTEX_HH

# include <pthread.h>

# include <stdexcept>

# include "non-copyable.hh"
# include "time.hh"
# include "locker.hh"
# include "shared-locker.hh"
# include "unique-locker.hh"

namespace mimosa
{
  /**
   * @ingroup Sync
   */
  class SharedMutex : private NonCopyable
  {
  public:
    typedef mimosa::Locker<SharedMutex>       Locker;
    typedef mimosa::SharedLocker<SharedMutex> ReadLocker;
    typedef mimosa::UniqueLocker<SharedMutex> UniqueLocker;

    inline SharedMutex()
      : lock_()
    {
      if (::pthread_rwlock_init(&lock_, nullptr))
        throw std::bad_alloc();
    }

    inline ~SharedMutex()
    {
      ::pthread_rwlock_destroy(&lock_);
    }

    inline void sharedLock()
    {
      ::pthread_rwlock_rdlock(&lock_);
    }

    inline void trySharedMutex()
    {
      ::pthread_rwlock_tryrdlock(&lock_);
    }

    inline bool timedSharedMutex(Time time)
    {
      ::timespec tp = toTimeSpec(time);
      return ::pthread_rwlock_timedrdlock(&lock_, &tp);
    }

    inline void lock()
    {
      ::pthread_rwlock_wrlock(&lock_);
    }

    inline void tryLock()
    {
      ::pthread_rwlock_trywrlock(&lock_);
    }

    inline bool timedLock(Time time)
    {
      ::timespec tp = toTimeSpec(time);
      return ::pthread_rwlock_timedwrlock(&lock_, &tp);
    }

    inline void unlock()
    {
      ::pthread_rwlock_unlock(&lock_);
    }

  private:
    ::pthread_rwlock_t lock_;
  };
}

#endif /* !MIMOSA_SHARED_MUTEX_HH */<commit_msg>Fix some weirdness with the shared mutex<commit_after>#ifndef MIMOSA_SHARED_MUTEX_HH
# define MIMOSA_SHARED_MUTEX_HH

# include <pthread.h>

# include <stdexcept>

# include "non-copyable.hh"
# include "time.hh"
# include "locker.hh"
# include "shared-locker.hh"
# include "unique-locker.hh"

namespace mimosa
{
  /**
   * @ingroup Sync
   */
  class SharedMutex : private NonCopyable
  {
  public:
    typedef mimosa::Locker<SharedMutex>       Locker;
    typedef mimosa::SharedLocker<SharedMutex> ReadLocker;
    typedef mimosa::UniqueLocker<SharedMutex> UniqueLocker;

    inline SharedMutex()
      : lock_()
    {
      if (::pthread_rwlock_init(&lock_, nullptr))
        throw std::bad_alloc();
    }

    inline ~SharedMutex()
    {
      ::pthread_rwlock_destroy(&lock_);
    }

    inline void sharedLock()
    {
      ::pthread_rwlock_rdlock(&lock_);
    }

    inline void trySharedLock()
    {
      ::pthread_rwlock_tryrdlock(&lock_);
    }

#ifndef __MACH__
    inline bool timedSharedLock(Time time)
    {
      ::timespec tp = toTimeSpec(time);
      return ::pthread_rwlock_timedrdlock(&lock_, &tp);
    }
#endif

    inline void lock()
    {
      ::pthread_rwlock_wrlock(&lock_);
    }

    inline void tryLock()
    {
      ::pthread_rwlock_trywrlock(&lock_);
    }

#ifndef __MACH__
    inline bool timedLock(Time time)
    {
      ::timespec tp = toTimeSpec(time);
      return ::pthread_rwlock_timedwrlock(&lock_, &tp);
    }
#endif

    inline void unlock()
    {
      ::pthread_rwlock_unlock(&lock_);
    }

  private:
    ::pthread_rwlock_t lock_;
  };
}

#endif /* !MIMOSA_SHARED_MUTEX_HH */
{'fraction_non_alphanumeric': 0.12195892575039495, 'fraction_numerical': 0.0, 'mean_word_length': 3.0331210191082802, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2935106', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1138, 'n_words': 196}