MCPcopy Create free account
hub / github.com/carbonengine/trinity / ExecuteMainThreadActions

Function ExecuteMainThreadActions

trinity/ContinueOnMainThread.cpp:20–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20void ExecuteMainThreadActions()
21{
22 CCP_STATS_ZONE( __FUNCTION__ );
23
24 static std::vector<std::function<void()>> actionsToProcess;
25
26 invocations++;
27 if( invocations > 1 )
28 {
29 return;
30 }
31
32 ON_BLOCK_EXIT( [] {
33 invocations = 0;
34 actionsToProcess.clear();
35 } );
36
37 while( invocations > 0 )
38 {
39 {
40 std::lock_guard<std::mutex> lock( mainThreadActionsMutex );
41 actionsToProcess.swap( mainThreadActions );
42 }
43 {
44 ScopedBlockTrap blockTrap;
45 for( auto& action : actionsToProcess )
46 {
47 action();
48 }
49 }
50 actionsToProcess.clear();
51 invocations--;
52 }
53}

Callers 2

OnTickMethod · 0.85
UpdateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected