Hi all, I've been working on solve an issue discussed on https://github.com/uber-go/ratelimit/pull/1#discussion-diff-78767601 . After a few attempts, I come up with a general solution to solve this one. (I already have PRed and now review is ongoing)
https://github.com/cat2neat/gopeek gopeek peeks goroutines and helps gophers cope with those in intuitive ways such as waiting for some goroutines to change its state into waiting a lock primitive and so on. The below is a example how to use. // Wait for goroutines // - created by a func that matches "gopeek_test.TestGoPeek.*" (Regex can be used) // - locked at a M (Any fields in stack.Gorotine can be used at user-defined filter) // - blocked by channel primitives // - the number of goroutines which satisfy the above conditions == 3 // Return goroutines that satisfy the above all conditions or // Timeout after time.Millisecond passed if no goroutines satisfy. gopeek.NewCondition(). CreatedBy("gopeek_test.TestGoPeek.*"). FilterByGo(func(g *stack.Gorotine) bool { return g.Signature.Locked }). Is(gopeek.StateWaitingChannel). EQ(3). Wait(time.Millisecond) You can make conditions that specify what state a goroutine is or what its function name is or how many goroutines that satisfy the all previous conditions exist etc.. with method chain manner and lastly call Wait if you want to wait for getting your goroutines satisfy those conditions or call Eval if you want to retrieve goroutines that satisfy those at the moment. As this library peeks go's internal source code to identify what status they are, so I can't grantee this implementation keep working but I will do my best. Now 1.6.x, 1.7.x and tips are working as expected. Any feedback, contributions or questions are appreciated. cat2neat -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.