Skip to content
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

future/promise集成度似乎还不够高 #1

Open
zER0pAGe-1 opened this issue Jul 23, 2018 · 1 comment
Open

future/promise集成度似乎还不够高 #1

zER0pAGe-1 opened this issue Jul 23, 2018 · 1 comment

Comments

@zER0pAGe-1
Copy link

网络的一些操作还是基于epoll的异步回调的,比如connector中的非阻塞连接行为, 能否具有类似
connect().then([] { onSuccess(); }) 的同步调用模式呢?
另外,同步阻塞操作的异步化都是通过线程池的方式实现的,这里能不能考虑使用协程而不是线程来避免线程上下文切换的开销呢?

@loveyacper
Copy link
Owner

loveyacper commented Jul 23, 2018

  • 第一个建议很好,考虑过,由于功能优先级问题搁置了,后续会改动,目前是事件驱动onConnect回调。另一个小原因是当时不想让网络库跟future过多耦合,鉴于future使用有一点门槛。

  • 由于cpp没有内置协程而且macos上swapcontext不正常,放弃了。另外hook系统调用也是个技巧活,不太想陷入其中。如果有好的建议欢迎pr,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants