参考:C定时器实现_c定时器,c定时器-C代码类资源-优快云下载
/unit-0.1/test/nxt_rbtree1.c
//util_timer.c
static void UtilSetNonBlocking(int sock)
{
int opts;
opts=fcntl(sock,F_GETFL);
if(opts<0)
{
perror("fcntl(sock,GETFL)");
exit(1);
}
opts = opts|O_NONBLOCK;
if(fcntl(sock,F_SETFL,opts)<0)
{
perror("fcntl(sock,SETFL,opts)");
exit(1);
}
}
gcc -pthread -D_DEBUG app_main.c util_rbtree.c util_timer.c -o timer.bin
gcc -I./include -L./lib -o app.bin -lpthread -lm ./main/*.c ./source/*.c ./lib/libqkssdk.a
本文介绍了一个使用C语言实现的定时器,并展示了如何通过设置非阻塞套接字来优化定时器的性能。此外,还提供了一个基于RB树的测试案例 nxt_rbtree1.c,以及编译定时器和RB树相关代码的具体步骤。
1767

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



