From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Misc/BatchDeleteObjects.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Runtime/Misc/BatchDeleteObjects.h (limited to 'Runtime/Misc/BatchDeleteObjects.h') diff --git a/Runtime/Misc/BatchDeleteObjects.h b/Runtime/Misc/BatchDeleteObjects.h new file mode 100644 index 0000000..096e9a1 --- /dev/null +++ b/Runtime/Misc/BatchDeleteObjects.h @@ -0,0 +1,31 @@ +#pragma once + +class Object; + +struct BatchDelete +{ + size_t reservedObjectCount; + size_t objectCount; + Object** objects; +}; + +// Creates a batch delete object. When the object array has been filled (All Object* must be set. The function does not set them to null) +// You can call CommitBatchDelete which will make the deletion thread delete the objects. +BatchDelete CreateBatchDelete (size_t size); + +// Makes the batch delete +void CommitBatchDelete (BatchDelete& batchDelete); + + +/// Deletes an array of objects identified by instanceID. Deallocation is done on another thread. +/// Callbacks like ScriptableObject.OnDestroy etc must be called before invoking this function. +void BatchDeleteObjectInternal (const SInt32* unloadObjects, int size); + + +// Used by the batch deletion to figure out if a specific class must be deallocated on the main thread. Eg. Textures need to be deallocate on the main thread +// Object::MainThreadCleanup will be called if this per class check returns true. +bool DoesClassRequireMainThreadDeallocation (int classID); + + +void InitializeBatchDelete (); +void CleanupBatchDelete (); \ No newline at end of file -- cgit v1.1-26-g67d0