BsDeferredCallManager.h 1.1 KB

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