#pragma once

#include <functional>

#include "Thread.h"

namespace Framework
{
    class AsynchronCall : private Thread
    {
    private:
        std::function<void()> f;
        bool* finished;

        void thread() override;
        void threadEnd() override;

    public:
        //! Constructor
        //! \param f The function to be called asynchronously
        //!  Must be called with new. The object deletes itself
        DLLEXPORT AsynchronCall(std::function<void()> f);
        //! Constructor
        //! \param name The name of the thread
        //! \param f The function to be called asynchronously
        //!  Must be called with new. The object deletes itself
        DLLEXPORT AsynchronCall(const char* name, std::function<void()> f);
        //! Constructor
        //! \param f The function to be called asynchronously
        //! \param finished Will be set to 1 when the call has been processed
        //!  Must be called with new. The object deletes itself
        DLLEXPORT AsynchronCall(std::function<void()> f, bool* finished);
        //! Constructor
        //! \param name The name of the thread
        //! \param f The function to be called asynchronously
        //! \param finished Will be set to 1 when the call has been processed
        //!  Must be called with new. The object deletes itself
        DLLEXPORT AsynchronCall(
            const char* name, std::function<void()> f, bool* finished);
    };
} // namespace Framework