<commit_before>#include "event_loop.h"
#include "rpc_man.h"
#include "SessionMan.h"
#include "WampTypes.h"
#include "Logger.h"


namespace XXX {

// TODO: set to 1000; for testing, set to 1 ms
#define SYSTEM_HEARTBEAT_MS 60000

/* Constructor */
event_loop::event_loop(Logger *logptr)
  : __logptr(logptr),
    m_continue(true),
    m_thread(&event_loop::eventmain, this),
    m_rpcman(nullptr),
    m_sesman(nullptr),
    m_handlers( WAMP_MSGID_MAX ), /* initial handles are empty */
    m_last_hb( std::chrono::steady_clock::now() )
{
}

/* Destructor */
event_loop::~event_loop()
{
  stop();
}

void event_loop::stop()
{
  m_continue = false;
  push( 0 );
  if (m_thread.joinable()) m_thread.join();
}

void event_loop::set_rpc_man(rpc_man* r)
{
  m_rpcman = r;
}

void event_loop::set_session_man(SessionMan* sm)
{
  m_sesman = sm;
}

void event_loop::set_handler(unsigned int eventid, event_cb handler)
{
  if (eventid > m_handlers.size() )
  {
    _ERROR_("resizing handler vector for eventid " << eventid);
    m_handlers.resize( eventid+1 );
  }
  m_handlers[ eventid ] = handler;

}

void event_loop::set_handler2(unsigned int eventid, event_cb2 handler)
{
  if (eventid > m_handlers2.size() )
  {
    _ERROR_("resizing handler vector for eventid " << eventid);
    m_handlers2.resize( eventid+1 );
  }
  m_handlers2[ eventid ] = handler;

}

/*
  shared_ptr<> sp
  push_
*/

// void push(std::shared_ptr<event>& ev)
// {
//   if (ev == 0) m_continue = false;<commit_msg>misleading error log statement<commit_after>#include "event_loop.h"
#include "rpc_man.h"
#include "SessionMan.h"
#include "WampTypes.h"
#include "Logger.h"


namespace XXX {

// TODO: set to 1000; for testing, set to 1 ms
#define SYSTEM_HEARTBEAT_MS 60000

/* Constructor */
event_loop::event_loop(Logger *logptr)
  : __logptr(logptr),
    m_continue(true),
    m_thread(&event_loop::eventmain, this),
    m_rpcman(nullptr),
    m_sesman(nullptr),
    m_handlers( WAMP_MSGID_MAX ), /* initial handles are empty */
    m_last_hb( std::chrono::steady_clock::now() )
{
}

/* Destructor */
event_loop::~event_loop()
{
  stop();
}

void event_loop::stop()
{
  m_continue = false;
  push( 0 );
  if (m_thread.joinable()) m_thread.join();
}

void event_loop::set_rpc_man(rpc_man* r)
{
  m_rpcman = r;
}

void event_loop::set_session_man(SessionMan* sm)
{
  m_sesman = sm;
}

void event_loop::set_handler(unsigned int eventid, event_cb handler)
{
  if (eventid > m_handlers.size() )
  {
    _ERROR_("resizing handler vector for eventid " << eventid);
    m_handlers.resize( eventid+1 );
  }
  m_handlers[ eventid ] = handler;

}

void event_loop::set_handler2(unsigned int eventid, event_cb2 handler)
{
  if (eventid > m_handlers2.size() )
  {
    m_handlers2.resize( eventid+1 );
  }
  m_handlers2[ eventid ] = handler;
}

/*
  shared_ptr<> sp
  push_
*/

// void push(std::shared_ptr<event>& ev)
// {
//   if (ev == 0) m_continue = false;
{'fraction_non_alphanumeric': 0.14732142857142858, 'fraction_numerical': 0.01304945054945055, 'mean_word_length': 4.174067495559503, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '52377', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1140, 'n_words': 226}