<commit_before>#include "cdrenderer.h"

#include <coffee/core/base/cfiles.h>
#include <coffee/core/plat/argument_parse.h>
#include <coffee/core/unit_tests/data_types.h>
#include <coffee/core/plat/environment_details.h>
#include <blam/cblam.h>

using namespace Coffee;
using namespace Coffee::CDisplay;

int main(int,char**)
{
    cstring_w cfg_dir = coffee_get_userdata_dir("hbirchtree","Best Coffee of All Time");
    cstring_w app_dir = coffee_get_application_dir();
    cstring_w exe_name = coffee_executable_name();

    cDebug("Settings directory: %s",cfg_dir);
    cDebug("Program directory:  %s",app_dir);
    cDebug("Launching from      %s",exe_name);

    CResources::CFiles::coffee_file_mkdir(cfg_dir,true);

    free(cfg_dir);
    free(app_dir);
    free(exe_name);

    Coffee::CoffeeInit();
    CoffeeTests::run_tests();

    CElapsedTimerMicro timer;
    timer.start();

    CDRenderer* renderer = new CDRenderer(nullptr);

    //Magic happens here
    CDWindowProperties props;

    props.flags |=
            CDWindowProperties::Minimized |
            CDWindowProperties::Decorated |
            CDWindowProperties::Resizable |
            CDWindowProperties::Windowed;
    props.size.w = 1280;
    props.size.h = 720;
    props.monitor = 0;

    props.contextProperties.flags |=
            CGLContextProperties::GLDebug |
            CGLContextProperties::GLAutoResize;
    props.contextProperties.version.major = 3;
    props.contextProperties.version.minor = 3;

    props.contextProperties.bits.alpha = 8;
    props.contextProperties.bits.red = 8;
    props.contextProperties.bits.blue = 8;
    props.contextProperties.bits.green = 8;
    props.contextProperties.bits.depth = 24;
    props.contextProperties.bits.stencil = 8;

    std::atomic<ubyte> atomic;
    atomic.store(0);
    CThreading::CThreadWorker<ubyte> worker(atomic);
//    std::future<void> ret = worker.run([=](){
//        try{
            renderer->run(props);
//        }catch(std::runtime_error exc){
//            cDebug("Caught exception in thread: 0x%llx, message: %s",std::this_thread::get_id(),exc.what());
//            worker.dataPtr()->store(1);
//            renderer->cleanup();
//        }
//        if(worker.dataPtr()->load()==0)
//            worker.dataPtr()->store(255);
//    });

//    while(worker.dataPtr()->load()==0)
//        std::this_thread::sleep_for(std::chrono::milliseconds(5));

    switch(worker.dataPtr()->load()){
    case 1:<commit_msg> - Re-enable multi-threaded running<commit_after>#include "cdrenderer.h"

#include <coffee/core/base/cfiles.h>
#include <coffee/core/plat/argument_parse.h>
#include <coffee/core/unit_tests/data_types.h>
#include <coffee/core/plat/environment_details.h>
#include <blam/cblam.h>

using namespace Coffee;
using namespace Coffee::CDisplay;

int main(int,char**)
{
    cstring_w cfg_dir = coffee_get_userdata_dir("hbirchtree","Best Coffee of All Time");
    cstring_w app_dir = coffee_get_application_dir();
    cstring_w exe_name = coffee_executable_name();

    cDebug("Settings directory: %s",cfg_dir);
    cDebug("Program directory:  %s",app_dir);
    cDebug("Launching from      %s",exe_name);

    CResources::CFiles::coffee_file_mkdir(cfg_dir,true);

    free(cfg_dir);
    free(app_dir);
    free(exe_name);

    Coffee::CoffeeInit();
    CoffeeTests::run_tests();

    CElapsedTimerMicro timer;
    timer.start();

    CDRenderer* renderer = new CDRenderer(nullptr);

    //Magic happens here
    CDWindowProperties props;

    props.flags |=
            CDWindowProperties::Minimized |
            CDWindowProperties::Decorated |
            CDWindowProperties::Resizable |
            CDWindowProperties::Windowed;
    props.size.w = 1280;
    props.size.h = 720;
    props.monitor = 0;

    props.contextProperties.flags |=
            CGLContextProperties::GLDebug |
            CGLContextProperties::GLAutoResize;
    props.contextProperties.version.major = 3;
    props.contextProperties.version.minor = 3;

    props.contextProperties.bits.alpha = 8;
    props.contextProperties.bits.red = 8;
    props.contextProperties.bits.blue = 8;
    props.contextProperties.bits.green = 8;
    props.contextProperties.bits.depth = 24;
    props.contextProperties.bits.stencil = 8;

    std::atomic<ubyte> atomic;
    atomic.store(0);
    CThreading::CThreadWorker<ubyte> worker(atomic);
    std::future<void> ret = worker.run([=](){
        try{
            renderer->run(props);
        }catch(std::runtime_error exc){
            cDebug("Caught exception in thread: 0x%llx, message: %s",std::this_thread::get_id(),exc.what());
            worker.dataPtr()->store(1);
            renderer->cleanup();
        }
        if(worker.dataPtr()->load()==0)
            worker.dataPtr()->store(255);
    });

    while(worker.dataPtr()->load()==0)
        std::this_thread::sleep_for(std::chrono::milliseconds(5));

    switch(worker.dataPtr()->load()){
    case 1:
{'fraction_non_alphanumeric': 0.14323445753758635, 'fraction_numerical': 0.010971149939049168, 'mean_word_length': 3.2958115183246073, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 33, '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': '7351333', 'n_tokens_mistral': 1657, 'n_tokens_neox': 1575, 'n_words': 238}