1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
3 | #pragma once |
4 | |
5 | #include "BsCorePrerequisites.h" |
6 | #include "Utility/BsModule.h" |
7 | |
8 | namespace bs |
9 | { |
10 | /** @addtogroup Utility-Core-Internal |
11 | * @{ |
12 | */ |
13 | |
14 | /** |
15 | * Allows you to queue calls that can get executed later. |
16 | * |
17 | * @note Sim thread only. |
18 | */ |
19 | class BS_CORE_EXPORT DeferredCallManager : public Module<DeferredCallManager> |
20 | { |
21 | public: |
22 | DeferredCallManager() = default; |
23 | |
24 | /** |
25 | * Register a deferred call that will be executed once at the start of next frame. |
26 | * |
27 | * @param[in] func The function to execute. |
28 | */ |
29 | void queueDeferredCall(std::function<void()> func); |
30 | |
31 | /** Executes all the scheduled calls. To be called once per frame. */ |
32 | void _update(); |
33 | |
34 | private: |
35 | friend class DeferredCall; |
36 | |
37 | Vector<std::function<void()>> mCallbacks; |
38 | }; |
39 | |
40 | /** @} */ |
41 | } |