AsyncOperationProcessingHandler.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #include <QThread>
  15. #endif
  16. namespace AZStd
  17. {
  18. class thread;
  19. }
  20. namespace AZ
  21. {
  22. namespace SceneAPI
  23. {
  24. namespace SceneUI
  25. {
  26. class SCENE_UI_API AsyncOperationProcessingHandler : public ProcessingHandler
  27. {
  28. Q_OBJECT
  29. public:
  30. AsyncOperationProcessingHandler(Uuid traceTag, AZStd::function<void()> targetFunction, AZStd::function<void()> onComplete = nullptr, QObject* parent = nullptr);
  31. ~AsyncOperationProcessingHandler() override = default;
  32. void BeginProcessing() override;
  33. private Q_SLOTS:
  34. void OnBackgroundOperationComplete();
  35. private:
  36. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  37. AZStd::function<void()> m_operationToRun;
  38. AZStd::function<void()> m_onComplete;
  39. QThread* m_thread = nullptr;
  40. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  41. };
  42. }
  43. }
  44. }