AsynchronCall.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include <functional>
  3. #include "Thread.h"
  4. namespace Framework
  5. {
  6. class AsynchronCall : private Thread
  7. {
  8. private:
  9. std::function<void()> f;
  10. bool* finished;
  11. void thread() override;
  12. void threadEnd() override;
  13. public:
  14. //! Constructor
  15. //! \param f The function to be called asynchronously
  16. //! Must be called with new. The object deletes itself
  17. DLLEXPORT AsynchronCall(std::function<void()> f);
  18. //! Constructor
  19. //! \param name The name of the thread
  20. //! \param f The function to be called asynchronously
  21. //! Must be called with new. The object deletes itself
  22. DLLEXPORT AsynchronCall(const char* name, std::function<void()> f);
  23. //! Constructor
  24. //! \param f The function to be called asynchronously
  25. //! \param finished Will be set to 1 when the call has been processed
  26. //! Must be called with new. The object deletes itself
  27. DLLEXPORT AsynchronCall(std::function<void()> f, bool* finished);
  28. //! Constructor
  29. //! \param name The name of the thread
  30. //! \param f The function to be called asynchronously
  31. //! \param finished Will be set to 1 when the call has been processed
  32. //! Must be called with new. The object deletes itself
  33. DLLEXPORT AsynchronCall(
  34. const char* name, std::function<void()> f, bool* finished);
  35. };
  36. } // namespace Framework