MCPcopy Create free account
hub / github.com/acl-dev/acl / trigger

Method trigger

lib_acl_cpp/src/event/event_timer.cpp:168–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166}
167
168acl_int64 event_timer::trigger(void)
169{
170 // sanity check
171 if (tasks_.empty()) {
172 return TIMER_EMPTY;
173 }
174
175 acl_assert(length_ > 0);
176
177 set_time();
178
179 std::list<event_task*> tasks;
180
181 // �Ӷ�ʱ����ȡ������Ķ�ʱ����
182 for (std::list<event_task*>::iterator it = tasks_.begin();
183 it != tasks_.end();) {
184
185 if ((*it)->when > present_) {
186 break;
187 }
188
189 tasks.push_back(*it);
190 it = tasks_.erase(it);
191 length_--;
192 }
193
194 if (tasks.empty()) {
195 acl_assert(!tasks_.empty());
196
197 event_task* first = tasks_.front();
198 acl_int64 delay = first->when - present_;
199 return delay < 0 ? 0 : delay;
200 }
201
202 for (std::list<event_task*>::iterator it = tasks.begin();
203 it != tasks.end(); ++it) {
204
205 set_task(*it);
206 // ���������麯����������ʱ���������
207 timer_callback((*it)->id);
208 }
209
210 tasks.clear();
211
212 // �����п��ܻ��� timer_callback ��ɾ�������еĶ�ʱ����
213 if (tasks_.empty()) {
214 return TIMER_EMPTY;
215 }
216
217 event_task* first = tasks_.front();
218 acl_int64 delay = first->when - present_;
219
220 if (delay < 0) {
221 return 0;
222 } else if (delay > first->delay) { /* xxx */
223 return first->delay;
224 } else {
225 return delay;

Callers

nothing calls this directly

Calls 6

timer_callbackFunction · 0.85
beginMethod · 0.80
emptyMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected