<commit_before>#include "MailBox.h"
#ifdef WIN32
#include "win32/Window.h"
#endif

CMailBox::CMailBox()
{

}

CMailBox::~CMailBox()
{

}

bool CMailBox::IsPending() const
{
    return m_calls.size() != 0;
}

void CMailBox::WaitForCall()
{
	boost::mutex::scoped_lock waitLock(m_waitMutex);
    while(!IsPending())
    {
        m_waitCondition.wait(waitLock);
    }
}

void CMailBox::WaitForCall(unsigned int timeOut)
{
    boost::mutex::scoped_lock waitLock(m_waitMutex);
    if(IsPending()) return;
    boost::xtime xt;
    boost::xtime_get(&xt, boost::TIME_UTC);
    xt.nsec += timeOut * 1000000;
    m_waitCondition.timed_wait(waitLock, xt);
}

void CMailBox::SendCall(const FunctionType& function, bool waitForCompletion)
{
    {
        boost::mutex::scoped_lock waitLock(m_waitMutex);
		MESSAGE message;
		message.function = function;
		message.sync = waitForCompletion;
        m_calls.push_back(message);
        m_waitCondition.notify_all();
    }
    if(waitForCompletion)
    {
        boost::mutex::scoped_lock doneLock(m_doneNotifyMutex);
        m_callDone = false;
		while(!m_callDone)
        {
#ifdef WIN32
	        MSG wmmsg;
            while(PeekMessage(&wmmsg, NULL, 0, 0, PM_REMOVE))
		    {
			    TranslateMessage(&wmmsg);
			    DispatchMessage(&wmmsg);
		    }
            boost::xtime xt;
            boost::xtime_get(&xt, boost::TIME_UTC);
            xt.nsec += 100 * 1000000;
            m_callFinished.timed_wait(doneLock, xt);
#else
            m_callFinished.wait(doneLock);
#endif
        }
    }
}

void CMailBox::ReceiveCall()
{
    MESSAGE message;
    {
        boost::mutex::scoped_lock waitLock(m_waitMutex);
        if(!IsPending()) return;
        message = *m_calls.begin();
        m_calls.pop_front();
    }
    message.function();
	if(message.sync)
    {
        boost::mutex::scoped_lock doneLock(m_doneNotifyMutex);
        m_callDone = true;
        m_callFinished.notify_all();
    }
}<commit_msg>Cleanup + compilation fixes for boost 1.50<commit_after>#include "MailBox.h"
#ifdef WIN32
#include "win32/Window.h"
#endif

CMailBox::CMailBox()
{

}

CMailBox::~CMailBox()
{

}

bool CMailBox::IsPending() const
{
	return m_calls.size() != 0;
}

void CMailBox::WaitForCall()
{
	boost::mutex::scoped_lock waitLock(m_waitMutex);
	while(!IsPending())
	{
		m_waitCondition.wait(waitLock);
	}
}

void CMailBox::WaitForCall(unsigned int timeOut)
{
	boost::mutex::scoped_lock waitLock(m_waitMutex);
	if(IsPending()) return;
	boost::xtime xt;
	boost::xtime_get(&xt, boost::TIME_UTC_);
	xt.nsec += timeOut * 1000000;
	m_waitCondition.timed_wait(waitLock, xt);
}

void CMailBox::SendCall(const FunctionType& function, bool waitForCompletion)
{
	{
		boost::mutex::scoped_lock waitLock(m_waitMutex);
		MESSAGE message;
		message.function = function;
		message.sync = waitForCompletion;
		m_calls.push_back(message);
		m_waitCondition.notify_all();
	}
	if(waitForCompletion)
	{
		boost::mutex::scoped_lock doneLock(m_doneNotifyMutex);
		m_callDone = false;
		while(!m_callDone)
		{
#ifdef WIN32
			MSG wmmsg;
			while(PeekMessage(&wmmsg, NULL, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&wmmsg);
				DispatchMessage(&wmmsg);
			}
			boost::xtime xt;
			boost::xtime_get(&xt, boost::TIME_UTC_);
			xt.nsec += 100 * 1000000;
			m_callFinished.timed_wait(doneLock, xt);
#else
			m_callFinished.wait(doneLock);
#endif
		}
	}
}

void CMailBox::ReceiveCall()
{
	MESSAGE message;
	{
		boost::mutex::scoped_lock waitLock(m_waitMutex);
		if(!IsPending()) return;
		message = *m_calls.begin();
		m_calls.pop_front();
	}
	message.function();
	if(message.sync)
	{
		boost::mutex::scoped_lock doneLock(m_doneNotifyMutex);
		m_callDone = true;
		m_callFinished.notify_all();
	}
}
{'fraction_non_alphanumeric': 0.13891891891891892, 'fraction_numerical': 0.014864864864864866, 'mean_word_length': 3.8890356671070014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4848067', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1378, 'n_words': 207}