BsDeferredCallManager.h 1.0 KB

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