We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code:
package main import ( "context" "fmt" "math/rand" "time" "github.com/alphadose/haxmap" ) type data struct { id int exp time.Time } func main() { c := haxmap.New[int, *data](256) ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { t := time.NewTicker(time.Second * 2) defer t.Stop() var count int for { select { case <-t.C: count = 0 c.ForEach(func(s int, b *data) bool { if time.Now().After(b.exp) { c.Del(s) count++ } return true }) fmt.Println("Del", count) case <-ctx.Done(): return } } }() for i := 0; i < 20000; i++ { c.Set(i, &data{id: i, exp: time.Now().Add(time.Millisecond * time.Duration((1000 + rand.Intn(800))))}) time.Sleep(time.Microsecond * time.Duration(rand.Intn(200)+10)) if i%100 == 0 { fmt.Println(i) } } time.Sleep(time.Second * 3) fmt.Println("LEN", c.Len()) }
Running the above code, setting the new Key will stop.
The text was updated successfully, but these errors were encountered:
@bagualing which version of haxmap are you using ?
Sorry, something went wrong.
haxmap v1.0.0 & go v1.19.1
@bagualing this issue is fixed in https://github.com/alphadose/haxmap/releases/tag/v1.0.1
the snippet you provided above is now working
I encourage you to test this yourself
Also many thanks for pointing this out :)
@alphadose Oh, that's great! Thanks for your excellent work!
No branches or pull requests
Code:
Running the above code, setting the new Key will stop.
The text was updated successfully, but these errors were encountered: