AsyncOperationProcessingHandler.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. /*
  3. * Copyright (c) Contributors to the Open 3D Engine Project.
  4. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. *
  6. * SPDX-License-Identifier: Apache-2.0 OR MIT
  7. *
  8. */
  9. #if !defined(Q_MOC_RUN)
  10. #include <SceneAPI/SceneUI/Handlers/ProcessingHandlers/ProcessingHandler.h>
  11. #include <AzCore/std/functional.h>
  12. #include <AzCore/std/smart_ptr/unique_ptr.h>
  13. #include <SceneAPI/SceneUI/SceneUIConfiguration.h>
  14. #endif
  15. namespace AZStd
  16. {
  17. class thread;
  18. }
  19. namespace AZ
  20. {
  21. namespace SceneAPI
  22. {
  23. namespace SceneUI
  24. {
  25. class SCENE_UI_API AsyncOperationProcessingHandler : public ProcessingHandler
  26. {
  27. Q_OBJECT
  28. public:
  29. AsyncOperationProcessingHandler(Uuid traceTag, AZStd::function<void()> targetFunction, AZStd::function<void()> onComplete = nullptr, QObject* parent = nullptr);
  30. ~AsyncOperationProcessingHandler() override = default;
  31. void BeginProcessing() override;
  32. private:
  33. void OnBackgroundOperationComplete();
  34. private:
  35. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  36. AZStd::function<void()> m_operationToRun;
  37. AZStd::function<void()> m_onComplete;
  38. AZStd::unique_ptr<AZStd::thread> m_thread;
  39. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  40. };
  41. }
  42. }
  43. }