MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Flush

Method Flush

Source/Engine/Core/ObjectsRemovalService.cpp:70–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70void ObjectsRemovalService::Flush(float dt, float gameDelta)
71{
72 PROFILE_CPU();
73
74 PoolLocker.Lock();
75 PoolCounter = 0;
76
77 // Update timeouts and delete objects that timed out
78 for (auto i = Pool.Begin(); i.IsNotEnd(); ++i)
79 {
80 auto& bucket = *i;
81 Object* obj = bucket.Key;
82 const float ttl = bucket.Value - ((obj->Flags & ObjectFlags::UseGameTimeForDelete) != ObjectFlags::None ? gameDelta : dt);
83 if (ttl <= 0.0f)
84 {
85 Pool.Remove(i);
86 obj->OnDeleteObject();
87 }
88 else
89 {
90 bucket.Value = ttl;
91 }
92 }
93
94 // If any object was added to the pool while removing objects (by this thread) then retry removing any nested objects (but without delta time)
95 if (PoolCounter != 0)
96 {
97 RETRY:
98 PoolCounter = 0;
99 for (auto i = Pool.Begin(); i.IsNotEnd(); ++i)
100 {
101 if (i->Value <= 0.0f)
102 {
103 Object* obj = i->Key;
104 Pool.Remove(i);
105 obj->OnDeleteObject();
106 }
107 }
108 if (PoolCounter != 0)
109 goto RETRY;
110 }
111
112 PoolLocker.Unlock();
113}
114
115bool ObjectsRemoval::Init()
116{

Callers

nothing calls this directly

Calls 6

LockMethod · 0.80
UnlockMethod · 0.80
BeginMethod · 0.45
IsNotEndMethod · 0.45
RemoveMethod · 0.45
OnDeleteObjectMethod · 0.45

Tested by

no test coverage detected