diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Misc/AsyncOperation.h |
Diffstat (limited to 'Runtime/Misc/AsyncOperation.h')
-rw-r--r-- | Runtime/Misc/AsyncOperation.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Runtime/Misc/AsyncOperation.h b/Runtime/Misc/AsyncOperation.h new file mode 100644 index 0000000..2ccb3e0 --- /dev/null +++ b/Runtime/Misc/AsyncOperation.h @@ -0,0 +1,38 @@ +#pragma once + +#include "Runtime/Threads/Mutex.h" +#include "Runtime/Threads/AtomicRefCounter.h" +#include "Runtime/BaseClasses/BaseObject.h" + +class AsyncOperation +{ + typedef void DelayedCall(Object* o, void* userData); + typedef void CleanupUserData (void* userData); + + AtomicRefCounter m_RefCount; + DelayedCall* m_CoroutineDone; + CleanupUserData* m_CoroutineCleanup; + void* m_CoroutineData; + PPtr<Object> m_CoroutineBehaviour; +public: + + AsyncOperation () { m_CoroutineDone = NULL; } + virtual ~AsyncOperation (); + virtual bool IsDone () = 0; + virtual float GetProgress () = 0; + + virtual int GetPriority () { return 0; } + virtual void SetPriority (int priority) { } + + virtual bool GetAllowSceneActivation () { return true; } + virtual void SetAllowSceneActivation (bool allow) { } + + void Retain (); + void Release (); + + bool HasCoroutineCallback () { return m_CoroutineDone != NULL; } + void SetCoroutineCallback ( DelayedCall* func, Object* coroutineBehaviour, void* userData, CleanupUserData* cleanup); + + void InvokeCoroutine (); + void CleanupCoroutine (); +}; |