<commit_before>#include "Mutex.h"
#include <cstdlib>

using namespace tpool::sync;

Mutex::Mutex()
{
  // TODO: check the return code.
  if (pthread_mutex_init(&m_mutex, NULL) != 0)
    {
      exit(1);
    }
}

Mutex::~Mutex()
{
  // TODO: check whether the mutex is in unlocked state.
  pthread_mutex_destroy(&m_mutex);
}

MutexLocker::MutexLocker(Mutex& m)
{
  m_mutex = &m;
  pthread_mutex_lock(&m.m_mutex);
}

MutexLocker::~MutexLocker()
{
  pthread_mutex_unlock(&(m_mutex->m_mutex));
}<commit_msg>Change the implementation of Mutex to throw runtime_error on error.<commit_after>#include "Mutex.h"
#include <cstdlib>
#include <stdexcept>

using namespace tpool::sync;
using namespace std;

Mutex::Mutex()
{
  // TODO: check the return code.
  if (pthread_mutex_init(&m_mutex, NULL) != 0)
    {
      throw runtime_error("failed to initialize mutex");
    }
}

Mutex::~Mutex()
{
  // TODO: check whether the mutex is in unlocked state.
  pthread_mutex_destroy(&m_mutex);
}

MutexLocker::MutexLocker(Mutex& m)
{
  m_mutex = &m;
  pthread_mutex_lock(&m.m_mutex);
}

MutexLocker::~MutexLocker()
{
  pthread_mutex_unlock(&(m_mutex->m_mutex));
}
{'fraction_non_alphanumeric': 0.14772727272727273, 'fraction_numerical': 0.0026223776223776225, 'mean_word_length': 4.6683168316831685, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, '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': '2586305', 'n_tokens_mistral': 429, 'n_tokens_neox': 445, 'n_words': 90}