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

Method Update

Source/Engine/Scripting/Scripting.cpp:246–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244#endif
245
246void ScriptingService::Update()
247{
248 PROFILE_CPU_NAMED("Scripting::Update");
249 INVOKE_EVENT(Update);
250
251 // Flush update actions
252 _objectsLocker.Lock();
253 int32 count = UpdateActions.Count();
254 for (int32 i = 0; i < count; i++)
255 {
256 UpdateActions[i]();
257 }
258 int32 newlyAdded = UpdateActions.Count() - count;
259 if (newlyAdded == 0)
260 UpdateActions.Clear();
261 else
262 {
263 // Someone added another action within current callback
264 Array<Function<void()>> tmp;
265 for (int32 i = newlyAdded; i < UpdateActions.Count(); i++)
266 tmp.Add(UpdateActions[i]);
267 UpdateActions.Clear();
268 UpdateActions.Add(tmp);
269 }
270 _objectsLocker.Unlock();
271
272#if defined(USE_NETCORE) && !USE_EDITOR
273 // Force GC to run in background periodically to avoid large blocking collections causing hitches
274 if (Time::Update.TicksCount % 60 == 0)
275 {
276 MCore::GC::Collect(MCore::GC::MaxGeneration(), MGCCollectionMode::Forced, false, false);
277 }
278#endif
279}
280
281void ScriptingService::LateUpdate()
282{

Callers

nothing calls this directly

Calls 6

CollectFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
CountMethod · 0.45
ClearMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected