设为首页 加入收藏

TOP

Epoll模型详解(十二)
2011-12-14 13:02:01 】 浏览:19770
Tags:Epoll 模型 详解
的数据传递出去

         struct user_data *data = NULL;

         while (1)

         {

                   pthread_mutex_lock(&mutex);

                   // 等待到任务队列不为空

                   while (readhead == NULL)

                            pthread_cond_wait(&cond1, &mutex);

                   fd = readhead->fd;

                   // 从任务队列取出一个读任务

                   struct task *tmp = readhead;

                   readhead = readhead->next;

                   delete tmp;

                   pthread_mutex_unlock(&mutex);

                   data = new user_data();

                   data->fd = fd;

                   if ((n = read(fd, data->line, MAXLINE)) < 0)

                   {

                            if (errno == ECONNRESET)

                            {

                                     close(fd);

                            } else

          

首页 上一页 9 10 11 12 13 下一页 尾页 12/13/13
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇libevent C 事件通知接口函数库 下一篇linux的epoll模型详解

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目