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

Function main

lib_acl_cpp/samples/aio/server_timer/main.cpp:253–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253int main(int argc, char* argv[])
254{
255 bool use_kernel = false, use_reactor = false;
256 int ch;
257 acl::string addr(":9001");
258
259 while ((ch = getopt(argc, argv, "l:hkL:t:r")) > 0) {
260 switch (ch) {
261 case 'h':
262 usage(argv[0]);
263 return 0;
264 case 'l':
265 addr = optarg;
266 break;
267 case 'k':
268 use_kernel = true;
269 break;
270 case 'L':
271 __max = atoi(optarg);
272 break;
273 case 't':
274 __timeout = atoi(optarg);
275 break;
276 case 'r':
277 use_reactor = true;
278 break;
279 default:
280 break;
281 }
282 }
283
284 // ��ʼ��ACL��(��������WIN32��һ��Ҫ���ô˺�������UNIXƽ̨�¿ɲ�����)
285 acl::acl_cpp_init();
286
287 acl::log::stdout_open(true);
288
289 // �����첽���������
290 acl::aio_handle handle(use_kernel ? acl::ENGINE_KERNEL : acl::ENGINE_SELECT);
291
292 long long delay = 1000000;
293 mytimer* timer = new mytimer(delay);
294 timer->keep_timer(true);
295 //handle.set_timer(timer, delay);
296
297 // ���������첽��
298 acl::aio_listen_stream* sstream = new acl::aio_listen_stream(&handle);
299
300 // ����ָ���ĵ�ַ
301 if (!sstream->open(addr.c_str())) {
302 std::cout << "open " << addr.c_str() << " error!" << std::endl;
303 sstream->destroy();
304 // XXX: Ϊ�˱�֤�ܹرռ�������Ӧ�ڴ˴��� check һ��
305 handle.check();
306
307 getchar();
308 return 1;
309 }
310

Callers

nothing calls this directly

Calls 11

acl_cpp_initFunction · 0.85
add_listen_callbackMethod · 0.80
add_accept_callbackMethod · 0.80
usageFunction · 0.70
getoptFunction · 0.50
keep_timerMethod · 0.45
openMethod · 0.45
c_strMethod · 0.45
destroyMethod · 0.45
checkMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…