#pragma once

#include <f4ll/console_handler.h>

#include <FreeRTOS.h>
#include <semphr.h>

class thread_safe_console_output
{
public:
    using size_type = f4ll::console_handler::size_type;
    thread_safe_console_output(f4ll::console_handler &console);

    void print(char const *s);
    void flush();
    size_type append(char const *s);

private:
    f4ll::console_handler &m_con;

    SemaphoreHandle_t m_sem;
    StaticSemaphore_t m_sem_buf;
};