1 Star 0 Fork 22

cuijinquan/gnet

forked from Gitee 极速下载/gnet 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
reactor_bsd.go 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
andypan 提交于 2019-11-17 00:30 . Remove deprecated code
// Copyright 2019 Andy Pan. All rights reserved.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
// +build darwin netbsd freebsd openbsd dragonfly
package gnet
import (
"github.com/panjf2000/gnet/netpoll"
)
func (svr *server) activateMainReactor() {
defer svr.signalShutdown()
_ = svr.mainLoop.poller.Polling(func(fd int, filter int16) error {
return svr.acceptNewConnection(fd)
})
}
func (svr *server) activateSubReactor(lp *loop) {
defer svr.signalShutdown()
if lp.idx == 0 && svr.opts.Ticker {
go lp.loopTicker()
}
_ = lp.poller.Polling(func(fd int, filter int16) error {
if c, ack := lp.connections[fd]; ack {
switch filter {
// Don't change the ordering of processing EVFILT_WRITE | EVFILT_READ | EV_ERROR/EV_EOF unless you're 100%
// sure what you're doing!
// Re-ordering can easily introduce bugs and bad side-effects, as I found out painfully in the past.
case netpoll.EVFilterWrite:
if !c.outboundBuffer.IsEmpty() {
return lp.loopOut(c)
}
return nil
case netpoll.EVFilterRead:
return lp.loopIn(c)
case netpoll.EVFilterSock:
return lp.loopCloseConn(c, nil)
}
}
return nil
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/cuijinquan/gnet.git
git@gitee.com:cuijinquan/gnet.git
cuijinquan
gnet
gnet
master

搜索帮助