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

Method trigger

lib_acl_cpp/src/stream/aio_timer_callback.cpp:162–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162acl_int64 aio_timer_callback::trigger()
163{
164 // sanity check
165 if (tasks_.empty()) {
166 return TIMER_EMPTY;
167 }
168
169 acl_assert(length_ > 0);
170
171 set_time();
172
173 std::list<aio_timer_task*>::iterator it;
174 std::list<aio_timer_task*> tasks;
175 aio_timer_task* task;
176
177 // �Ӷ�ʱ����ȡ������Ķ�ʱ����
178 for (it = tasks_.begin(); it != tasks_.end();) {
179 if ((*it)->when > present_) {
180 break;
181 }
182 task = *it;
183 it = tasks_.erase(it);
184 length_--;
185 tasks.push_back(task);
186 }
187
188 // �п�����Щ����Ķ�ʱ�����Ѿ����û���ǰɾ����
189 if (tasks.empty()) {
190 acl_assert(!tasks_.empty());
191
192 aio_timer_task* first = tasks_.front();
193 acl_int64 delay = first->when - present_;
194 return delay < 0 ? 0 : delay;
195 }
196
197 // ������Ķ�ʱ�������·Ż�����ʱ���������б��У�
198 // ����ʼ�������еĵ���Ķ�ʱ����
199
200 // ���������ô�������æ״̬���Է�ֹ�����ڻص�����
201 // �е����˸���������������
202 set_locked();
203
204 // ���ý��������ٱ�־Ϊ false����Ϊ��ǰ�ö�ʱ������
205 // ����״̬�����������������ֱ��������ʱ���ٱ���
206 // ���󣬵�����������ñ�ʶ����Ϊ true���������
207 // Ӧ���Զ�����
208 destroy_on_unlock_ = false;
209
210 for (it = tasks.begin(); it != tasks.end(); ++it) {
211 set_task(*it);
212 timer_callback((*it)->id);
213 }
214
215 tasks.clear();
216
217 // ����֮��IJ����б����������������
218 unset_locked();
219

Callers 1

on_timer_callbackMethod · 0.45

Calls 7

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

Tested by

no test coverage detected