MCPcopy Create free account
hub / github.com/defold/defold / AllocateTimer

Function AllocateTimer

engine/script/src/script_timer.cpp:107–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105 }
106
107 static Timer* AllocateTimer(HTimerWorld timer_world, uintptr_t owner)
108 {
109 assert(timer_world != 0x0);
110
111 if (timer_world->m_Timers.Full() && timer_world->m_Timers.Capacity() == MAX_TIMER_CAPACITY)
112 {
113 dmLogError("Timer could not be stored since the timer buffer is full (%d).", MAX_TIMER_CAPACITY);
114 return 0x0;
115 }
116
117 if (timer_world->m_Timers.Full())
118 {
119 uint32_t cap = timer_world->m_Timers.Capacity() + TIMER_CAPACITY_GROWTH;
120 if (cap > MAX_TIMER_CAPACITY)
121 cap = MAX_TIMER_CAPACITY;
122 timer_world->m_Timers.SetCapacity(cap);
123 timer_world->m_Instances.SetCapacity(cap);
124 }
125
126 uint16_t timer_index = (uint16_t)timer_world->m_Timers.Alloc();
127 Timer* timer = &timer_world->m_Timers.Get(timer_index);
128 timer_world->m_Instances.Add(timer_index);
129
130 memset(timer, 0, sizeof(Timer));
131 timer->m_Handle = MakeHandle(timer_world->m_Version, timer_index);
132 timer->m_Owner = owner;
133
134 timer_world->m_IsDirty = 1;
135 return timer;
136 }
137
138 static void DeallocateTimer(HTimerWorld timer_world, uint16_t timer_index)
139 {

Callers 1

AddTimerFunction · 0.85

Calls 8

AllocMethod · 0.80
MakeHandleFunction · 0.70
assertFunction · 0.50
FullMethod · 0.45
CapacityMethod · 0.45
SetCapacityMethod · 0.45
GetMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected