CmDeferredCallManager.h 730 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmModule.h"
  4. namespace CamelotFramework
  5. {
  6. /**
  7. * @brief Allows you to queue calls that can get executed later.
  8. *
  9. * @note Sim thread only.
  10. */
  11. class CM_EXPORT DeferredCallManager : public Module<DeferredCallManager>
  12. {
  13. public:
  14. DeferredCallManager();
  15. /**
  16. * @brief Register a deferred call that will be executed once at the start of next frame.
  17. *
  18. * @param func The function to execute.
  19. */
  20. void queueDeferredCall(std::function<void()> func);
  21. /**
  22. * @brief Executes all the scheduled calls.
  23. */
  24. void update();
  25. private:
  26. friend class DeferredCall;
  27. Vector<std::function<void()>>::type mCallbacks;
  28. };
  29. }