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

Add async std{in/out/err} #15

Merged
merged 3 commits into from
Apr 25, 2024
Merged

Add async std{in/out/err} #15

merged 3 commits into from
Apr 25, 2024

Conversation

uchenily
Copy link
Contributor

No description provided.

@8sileus
Copy link
Owner

8sileus commented Apr 24, 2024

我认为应该尽可能模仿标准库的行为吧,0 1 2描述符默认就是打开的,我认为没必要管理他们,有的用户可能会关闭out,然后自己打开一个文件描述符,从而实现一些操作。感觉最好把这三个封装成单例就行了,不用在内部处理返回值,然后最好用流来写这些玩意,最后。有考虑实现print println,eprintln会这些东西吗。

@uchenily
Copy link
Contributor Author

  1. 这里说的没必要管理他们是指 没必要添加异步的close方法吗?
  2. 对于文件描述符不用默认0/1/2的情况, 倒是也有办法比如通过fileno()找到对应的fd, 不过既然fd可能变化那封装成单例是不是就不合适了?
  3. 这里的Fd类没有使用io.hpp里面的那个就是因为stdin/stdout/stderr和其他的fd相比有些特殊, 默认打开, 而且也不需要析构的时候立刻关闭, 所以才创建了这么个单独的类.
  4. print/println/eprintln 这几个方法在实现stdout/stderr的write方法后就很容易实现了吧?

@8sileus
Copy link
Owner

8sileus commented Apr 24, 2024

抱歉之前没注意看,直接把in out err作为async read/write模板参数就行了。template这样。

@8sileus
Copy link
Owner

8sileus commented Apr 24, 2024

然后最好是不直接提供这些对象,在外面用print eprint包装一层更好

@uchenily
Copy link
Contributor Author

done

@8sileus 8sileus merged commit 0b790bc into 8sileus:main Apr 25, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants