#include <sys/epoll.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
int test(){
struct epoll_event;
int epfd;
struct timeval tv;
epfd=epoll_create(1);
while(1){
int nfds = epoll_wait(epfd, NULL, 1, 1000);
gettimeofday(&tv , NULL);
printf("%d hahaha\n", tv.tv_sec);
}
}
int main(){
test();
}用epoll实现毫秒sleep
最新推荐文章于 2025-04-02 10:22:17 发布
本文展示了一个使用epoll实现的简易定时任务程序。通过epoll_create创建epoll实例,并利用epoll_wait等待事件发生。每秒输出当前时间戳,演示了如何在Linux环境下进行事件驱动编程。
7409

被折叠的 条评论
为什么被折叠?



