一个简单的测试实例:
void acall(evutil_socket_t af, short, void *param)
{
std::cout << "calling" << std::endl;
}
sfd = open("a.txt", 'r');
struct event_config *cfg = event_config_new();
event_config_avoid_method(cfg, "epoll");
event_base *bev = event_base_new_with_config(cfg);//event_base_new();
event_config_free(cfg);
event *evn = event_new(bev, sfd, EV_READ| EV_WRITE |EV_PERSIST, acall, 0);
std::cout << "open:" << sfd << std::endl;
int e = event_initialized(evn);
std::cout << "init:" << e << std::endl;
e = event_add(evn, 0);
std::cout << "ADD:" << e << std::endl;
event_set_log_callback(logfn);
char buff[256];
read(sfd, buff, 12);
std::cout << buff << std::endl;
pthread_t pf;
pthread_create(&pf, NULL, rfile, NULL);
e = event_base_dispatch(bev);
pthread_join(pf, NULL);