Coder Social home page Coder Social logo

go-eden / routine Goto Github PK

View Code? Open in Web Editor NEW
111.0 3.0 19.0 44 KB

Provides some convenient API, includes Goid(), GetG() and LocalStorage, which is a goroutine's local storage, just like ThreadLocal in other languages.

License: MIT License

Go 84.93% Assembly 13.23% C 1.84%
goid localstorage threadlocal goroutine

routine's Issues

提了一个pr

提了一个pr,使用go的地方加了recover的保护,要不一个panic就可能导致整个进程退出

relocation target type.runtime.g not defined

go version go1.20.4 darwin/amd64

# github.com/go-eden/routine/internal/g.test
github.com/go-eden/routine/internal/g.getg0: relocation target type.runtime.g not defined
FAIL	github.com/go-eden/routine/internal/g [build failed]

希望添加来源声明

看了最新版本源码,其中 goid 获取方式基本参考了我的 gohack 项目。希望作者能声明下来源和地址,谢谢!

getAllGoidByNative中是否不应该过滤gDead

if runtimeReadgstatus(gp) == gDead || runtimeIsSystemGoroutine(gp, false) {
    continue
}

在系统调用/cgo/新建g的时候, g的状态也是gDead, 是否不应该在这里过滤掉gDead状态的g
因为这里的g状态虽然是dead,但等一会还是会恢复成runnable
cgo调用

支持go的1.21版本不?

目前是不是不支持go1.21版本,我尝试了一下报错
github.com/go-eden/routine/internal/g.getg0: relocation target type.runtime.g not defined

请问支持go1.17 arm64架构吗

使用的时候报错如下:
goroutine 1 [running, locked to thread]:
runtime.throw({0x10226d3d6, 0x5})
/usr/local/go/src/runtime/panic.go:1198 +0x54 fp=0x14000068c60 sp=0x14000068c30 pc=0x10220db94
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:742 +0x1e4 fp=0x14000068ca0 sp=0x14000068c60 pc=0x102223e04
github.com/go-eden/routine.getGoidByNative()
/Users/markma/go/pkg/mod/github.com/go-eden/[email protected]/routine_goid.go:75 +0x48 fp=0x14000068cd0 sp=0x14000068cb0 pc=0x10226c1f8
github.com/go-eden/routine.Goid()
/Users/markma/go/pkg/mod/github.com/go-eden/[email protected]/routine_api.go:69 +0x20 fp=0x14000068cf0 sp=0x14000068cd0 pc=0x10226bec0
github.com/go-eden/routine.loadCurrentStore()
/Users/markma/go/pkg/mod/github.com/go-eden/[email protected]/routine_storage.go:77 +0x20 fp=0x14000068dd0 sp=0x14000068cf0 pc=0x10226c720
github.com/go-eden/routine.(*storage).Clear(...)
/Users/markma/go/pkg/mod/github.com/go-eden/[email protected]/routine_storage.go:70
github.com/go-eden/routine.NewLocalStorage()
/Users/markma/go/pkg/mod/github.com/go-eden/[email protected]/routine_api.go:60 +0x24 fp=0x14000068df0 sp=0x14000068dd0 pc=0x10226be24
main.init()
/Users/markma/GolandProjects/awesomeProject/main.go:8 +0x20 fp=0x14000068e10 sp=0x14000068df0 pc=0x10226ce20
runtime.doInit(0x102305aa0)
/usr/local/go/src/runtime/proc.go:6498 +0x138 fp=0x14000068f70 sp=0x14000068e10 pc=0x10221edb8
runtime.main()
/usr/local/go/src/runtime/proc.go:238 +0x22c fp=0x14000068fd0 sp=0x14000068f70 pc=0x10221032c
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1133 +0x4 fp=0x14000068fd0 sp=0x14000068fd0 pc=0x10223b924

go env 如下
GO111MODULE="on"
GOARCH="arm64"
GOBIN="/usr/local/go/bin"
GOCACHE="/Users/markma/Library/Caches/go-build"
GOENV="/Users/markma/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/markma/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/markma/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/markma/GolandProjects/awesomeProject/go.mod"

Func getGoidByNative

Env:mac Darwin Kernel Version 20.4.0 arm64
Problem :
image

Compare p equals to nil is necessary?
pr: #5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.