1 Star 0 Fork 0

李文建/protoactor-go

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
untyped.go 715 Bytes
一键复制 编辑 原始数据 按行查看 历史
Potter Dai 提交于 2019-04-29 02:09 +08:00 . Merge branch 'dev' into stopper-context
package stream
import "github.com/AsynkronIT/protoactor-go/actor"
type UntypedStream struct {
c chan interface{}
pid *actor.PID
}
func (s *UntypedStream) C() <-chan interface{} {
return s.c
}
func (s *UntypedStream) PID() *actor.PID {
return s.pid
}
func (s *UntypedStream) Close() {
actor.EmptyRootContext.Stop(s.pid)
close(s.c)
}
func NewUntypedStream() *UntypedStream {
c := make(chan interface{})
props := actor.PropsFromFunc(func(ctx actor.Context) {
switch msg := ctx.Message().(type) {
case actor.AutoReceiveMessage, actor.SystemMessage:
// ignore terminate
default:
c <- msg
}
})
pid := actor.EmptyRootContext.Spawn(props)
return &UntypedStream{
c: c,
pid: pid,
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lwj8507/protoactor-go.git
git@gitee.com:lwj8507/protoactor-go.git
lwj8507
protoactor-go
protoactor-go
v0.0.1

搜索帮助