jordanbangia / signaler

Tell your waiting goroutines that something happened

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

signaler

Tell your waiting goroutines that something happened in a threadsafe way.

ctx := context.Background()

s := signaler.New()

go func() {
    select {
        case <-ctx.Done():
            return
        case <-s.Subscribe():
            fmt.Println("I got the signal!")
    }
}()

time.Sleep(10 * time.Second)
s.Trigger()

About

Tell your waiting goroutines that something happened

License:MIT License


Languages

Language:Go 100.0%