<commit_before>#include "multiproducer_oneconsumer.hpp"

#include "../base/logging.hpp"
#include "../base/macros.hpp"
#include "../base/assert.hpp"


MultiProducerOneConsumer::MultiProducerOneConsumer(size_t tasksPerThread)
#if PARALLEL_POLYGONIZER
  : m_ThreadPoolSemaphore(m_ThreadPool.maxThreadCount() * tasksPerThread)
#endif
{
#if PARALLEL_POLYGONIZER
  LOG(LINFO, ("QThreadPool threads count = ", m_ThreadPool.maxThreadCount()));
#endif
}

void MultiProducerOneConsumer::RunTask(ITask * pTask)
{
#if PARALLEL_POLYGONIZER
  ASSERT ( pTask->autoDelete(), () );
  pTask->BeforeStart(this);
  m_ThreadPool.start(pTask);

#else
  pTask->RunBase();
  delete pTask;

#endif
}

#if PARALLEL_POLYGONIZER
void MultiProducerOneConsumer::ITask::BeforeStart(MultiProducerOneConsumer * pParent)
{
  ASSERT ( pParent, () );
  m_pParent = pParent;
  m_pParent->m_ThreadPoolSemaphore.acquire();
}

void MultiProducerOneConsumer::ITask::run()
{
  RunBase();

  m_pParent->m_ThreadPoolSemaphore.release();
}
#endif

void MultiProducerOneConsumer::ITask::Emit(void * p)
{
#if PARALLEL_POLYGONIZER
  ASSERT ( m_pParent, () );<commit_msg>Revert "Add assert for auto delete."<commit_after>#include "multiproducer_oneconsumer.hpp"

#include "../base/logging.hpp"
#include "../base/macros.hpp"
#include "../base/assert.hpp"


MultiProducerOneConsumer::MultiProducerOneConsumer(size_t tasksPerThread)
#if PARALLEL_POLYGONIZER
  : m_ThreadPoolSemaphore(m_ThreadPool.maxThreadCount() * tasksPerThread)
#endif
{
#if PARALLEL_POLYGONIZER
  LOG(LINFO, ("QThreadPool threads count = ", m_ThreadPool.maxThreadCount()));
#endif
}

void MultiProducerOneConsumer::RunTask(ITask * pTask)
{
#if PARALLEL_POLYGONIZER
  pTask->BeforeStart(this);
  m_ThreadPool.start(pTask);

#else
  pTask->RunBase();
  delete pTask;

#endif
}

#if PARALLEL_POLYGONIZER
void MultiProducerOneConsumer::ITask::BeforeStart(MultiProducerOneConsumer * pParent)
{
  ASSERT ( pParent, () );
  m_pParent = pParent;
  m_pParent->m_ThreadPoolSemaphore.acquire();
}

void MultiProducerOneConsumer::ITask::run()
{
  RunBase();

  m_pParent->m_ThreadPoolSemaphore.release();
}
#endif

void MultiProducerOneConsumer::ITask::Emit(void * p)
{
#if PARALLEL_POLYGONIZER
  ASSERT ( m_pParent, () );
{'fraction_non_alphanumeric': 0.1341408703454464, 'fraction_numerical': 0.0, 'mean_word_length': 6.6632302405498285, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4540492', 'n_tokens_mistral': 842, 'n_tokens_neox': 839, 'n_words': 121}