欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Libevent 源码阅读--典型应用中的函数调用关系

程序员文章站 2022-06-01 16:22:44
...

一次典型应用的函数调用

struct event ev;
struct event_base *base;
struct event_base *base = event_base_new();
event_set(&ev, fd, EV_READ|EV_PERSIST, callback_fn, (void *)arg);
		|
		|__> event_assign(ev, current_base, fd, events, callback, arg)
					|
					|____>  ev->ev_base = base;
                                                ev->ev_callback = callback;
						ev->ev_arg = arg;
						ev->ev_fd = fd;
event_base_dispatch(base);
	   |
	   |__>event_base_loop(base,0)
				|
				|__> res = evsel->dispatch(base, tv_p);
				|				|
				|				|_____>epoll_wait
				|
                                |__>event_process_active (base)
					                |
		                            |__>event_process_active_single_queue				                    		                        
                                           |
				                    	   |__>
                                               evcb_callback =*ev->ev_callback;
                                               evcb_callback(ev->ev_fd, res, ev->ev_arg);
	                                                |
	                                                |___> accept

 

相关标签: 技术积累