BsDeferredCallManager.h 759 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Allows you to queue calls that can get executed later.
  8. *
  9. * @note Sim thread only.
  10. */
  11. class BS_CORE_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. To be called once per frame.
  23. *
  24. * @note Internal method.
  25. */
  26. void _update();
  27. private:
  28. friend class DeferredCall;
  29. Vector<std::function<void()>> mCallbacks;
  30. };
  31. }