BsDeferredCallManager.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //__________________________ Banshee Project - A modern game development toolkit _________________________________//
  2. //_____________________________________ www.banshee-project.com __________________________________________________//
  3. //________________________ Copyright (c) 2014 Marko Pintera. All rights reserved. ________________________________//
  4. #pragma once
  5. #include "BsCorePrerequisites.h"
  6. #include "BsModule.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief Allows you to queue calls that can get executed later.
  11. *
  12. * @note Sim thread only.
  13. */
  14. class BS_CORE_EXPORT DeferredCallManager : public Module<DeferredCallManager>
  15. {
  16. public:
  17. DeferredCallManager();
  18. /**
  19. * @brief Register a deferred call that will be executed once at the start of next frame.
  20. *
  21. * @param func The function to execute.
  22. */
  23. void queueDeferredCall(std::function<void()> func);
  24. /**
  25. * @brief Executes all the scheduled calls. To be called once per frame.
  26. *
  27. * @note Internal method.
  28. */
  29. void _update();
  30. private:
  31. friend class DeferredCall;
  32. Vector<std::function<void()>> mCallbacks;
  33. };
  34. }