New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于ep_wait问题 #790
Comments
事件不要了?这样不知道每一个fd的情况吧
…On Wed, Jan 10, 2018 at 9:55 AM, lindxmooc ***@***.***> wrote:
云风大神,我想请教一下,如果我只是在Linux下开发,这个
static int
sp_wait(int efd, struct event *e, int max) {
struct epoll_event ev[max];
int n = epoll_wait(efd , ev, max, -1);
int i;
for (i=0;i<n;i++) {
e[i].s = ev[i].data.ptr;
unsigned flag = ev[i].events;
e[i].write = (flag & EPOLLOUT) != 0;
e[i].read = (flag & EPOLLIN) != 0;
}
return n;
}
是否可以改成这样:
static int
sp_wait1(int efd, **struct epoll_event ev*, int max) {
int n = epoll_wait(efd , ev, max, -1);
return n;
}
不做for循环,毕竟在socket_server_poll()函数里已经有一个for (;;) {...}了,这样做,会不会高效点?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#790>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACArtlh_PdFxLZNOTzkKtvdJGsmMQxIiks5tJBiIgaJpZM4RYs0K>
.
|
我是在这里修改处理了:
其中的 evs是我在struct socket_server结构体里加上的: |
这样做可以吗,对于只在Linux下开发,能提高一点效率吗? |
不能,这岂不是用一块栈空间代替了指针…,还有这样操作的?
… 在 2018年1月10日,上午10:47,lindxmooc ***@***.***> 写道:
这样做可以吗,对于只在Linux下开发,能提高一点效率吗?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#790 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AS_5y_wF38bM889DK6jaIFPjLpsqa3zIks5tJCTIgaJpZM4RYs0K>.
|
你的程序效率出现问题了? |
不是,我是在了解源码的时候看到的,所以才产生这个疑问,比如现在有6400个连接服务器,感觉就for循环了6400 * 2,因为ep_wait会分成100次回调,在每一次当中,sp_wait中for循环64次,在外面又循环处理64次,不知道是不是这样理解? |
不是这样理解的,这块代码的意思是外循环的代码都是处理事件的,只有当事件处理完了才会进入sp_wait阻塞等待并获取事件,获取到事件后又会进入外循环处理事件,处理完了就再进入sp_wait阻塞等待并获取事件, 然后就这样循环下去….; 其实我们是可以将外面处理事件的代码放到sp_wait里的循环里执行的,只是云大没有那样写而已,每个人的代码书写习惯不一样,你再看看吧.
… 在 2018年1月15日,下午10:12,lindxmooc ***@***.***> 写道:
不是,我是在了解源码的时候看到的,所以才产生这个疑问,比如现在有6400个连接服务器,感觉就for循环了6400 * 2,因为ep_wait会分成100次回调,在每一次当中,sp_wait中for循环64次,在外面又循环处理64次,不知道是不是这样理解?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#790 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AS_5y1D-vJV9Ks69mjARKm49tiXiBnc9ks5tK1zTgaJpZM4RYs0K>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
云风大神,我想请教一下,如果我只是在Linux下开发,这个
static int
sp_wait(int efd, struct event *e, int max) {
struct epoll_event ev[max];
int n = epoll_wait(efd , ev, max, -1);
int i;
for (i=0;i<n;i++) {
e[i].s = ev[i].data.ptr;
unsigned flag = ev[i].events;
e[i].write = (flag & EPOLLOUT) != 0;
e[i].read = (flag & EPOLLIN) != 0;
}
}
是否可以改成这样:
static int
sp_wait1(int efd, *struct epoll_event ev, int max) {
int n = epoll_wait(efd , ev, max, -1);
return n;
}
不做for循环,毕竟在socket_server_poll()函数里已经有一个for (;;) {...}了,这样做,会不会高效点?
The text was updated successfully, but these errors were encountered: