BsDeferredCallManager.h 836 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. namespace BansheeEngine
  5. {
  6. /** @cond INTERNAL */
  7. /** @addtogroup Utility-Core
  8. * @{
  9. */
  10. /**
  11. * Allows you to queue calls that can get executed later.
  12. *
  13. * @note Sim thread only.
  14. */
  15. class BS_CORE_EXPORT DeferredCallManager : public Module<DeferredCallManager>
  16. {
  17. public:
  18. DeferredCallManager();
  19. /**
  20. * Register a deferred call that will be executed once at the start of next frame.
  21. *
  22. * @param[in] func The function to execute.
  23. */
  24. void queueDeferredCall(std::function<void()> func);
  25. /** Executes all the scheduled calls. To be called once per frame. */
  26. void _update();
  27. private:
  28. friend class DeferredCall;
  29. Vector<std::function<void()>> mCallbacks;
  30. };
  31. /** @} */
  32. /** @endcond */
  33. }