Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xujintao/go-libuv
试试golang的syscall
https://github.com/xujintao/go-libuv
Last synced: 4 days ago
JSON representation
试试golang的syscall
- Host: GitHub
- URL: https://github.com/xujintao/go-libuv
- Owner: xujintao
- Created: 2019-07-20T14:29:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-07-24T18:12:55.000Z (over 5 years ago)
- Last Synced: 2024-05-01T07:53:21.084Z (9 months ago)
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## golang协程异步io复用模型
每个fd的封装类型都需要组合internal/poll.FD类型,然后由后者去做io
对于进程继承来的标准fd(0,1,2),先包装一下,然后internal/poll.FD依然使用阻塞方式去io
对于自己打开的fd,也是先包装一下,然后internal/poll.FD统一使用异步复用方式进行io,golang使用协程把它模拟成阻塞方式
```
listener/conn-----net.(*netFD)-------
|-------internal/poll.(*FD)----------runtime跨平台支持poll
os.(*file) -------- (支持blocking和poll)
```## libuv事件驱动异步io复用模型
```
listener/conn------net.(*netFD)------
|--------go-libuv/poll.(*PollDesc)---不需要runtime支持
os.(*file)-------- (现在只支持linux)
(not yet)
```#### usage
```
package mainimport (
"log""github.com/xujintao/go-libuv/net/http"
"github.com/xujintao/go-libuv/poll"
)func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
http.ListenAndServe(":8080")
poll.Wait()
}
```