diff -Nru golang-golang-x-time-0.0~git20160202.0.a4bde12/debian/changelog golang-golang-x-time-0.0~git20161028.0.f51c127/debian/changelog --- golang-golang-x-time-0.0~git20160202.0.a4bde12/debian/changelog 2016-08-15 13:25:34.000000000 +0000 +++ golang-golang-x-time-0.0~git20161028.0.f51c127/debian/changelog 2017-06-21 11:43:39.000000000 +0000 @@ -1,3 +1,24 @@ +golang-golang-x-time (0.0~git20161028.0.f51c127-2) unstable; urgency=medium + + * Upload to unstable version already in experimental. + + -- Martín Ferrari Wed, 21 Jun 2017 11:43:39 +0000 + +golang-golang-x-time (0.0~git20161028.0.f51c127-1) experimental; urgency=medium + + [ Tim Potter ] + * New upstream snapshot. + + [ Martín Ferrari ] + * Add myself to Uploaders. + * debian/control: Remove golang-go dependency from -dev package. + * debian/control: Replace golang-go with golang-any in Build-Depends. + + [ Michael Stapelberg ] + * Add myself to Uploaders. + + -- Michael Stapelberg Mon, 13 Mar 2017 08:51:50 +0100 + golang-golang-x-time (0.0~git20160202.0.a4bde12-2) unstable; urgency=medium * Correced XS-Go-Import-Path. diff -Nru golang-golang-x-time-0.0~git20160202.0.a4bde12/debian/control golang-golang-x-time-0.0~git20161028.0.f51c127/debian/control --- golang-golang-x-time-0.0~git20160202.0.a4bde12/debian/control 2016-08-15 04:55:58.000000000 +0000 +++ golang-golang-x-time-0.0~git20161028.0.f51c127/debian/control 2017-06-21 11:43:39.000000000 +0000 @@ -2,11 +2,14 @@ Section: devel Priority: extra Maintainer: Debian Go Packaging Team -Uploaders: Dmitry Smirnov +Uploaders: Dmitry Smirnov , + Martín Ferrari , + Tim Potter , + Michael Stapelberg , Build-Depends: debhelper (>= 9), dh-golang, - golang-go, - golang-golang-x-net-dev + golang-any, + golang-golang-x-net-dev, Standards-Version: 3.9.8 Homepage: https://golang.org/x/time/rate Vcs-Browser: https://anonscm.debian.org/cgit/pkg-go/packages/golang-golang-x-time.git @@ -15,9 +18,8 @@ Package: golang-golang-x-time-dev Architecture: all -Depends: ${shlibs:Depends}, - ${misc:Depends}, - golang-go, - golang-golang-x-net-dev +Depends: ${misc:Depends}, + ${shlibs:Depends}, + golang-golang-x-net-dev, Description: Go supplementary time packages Supplementary Go time packages. diff -Nru golang-golang-x-time-0.0~git20160202.0.a4bde12/rate/rate.go golang-golang-x-time-0.0~git20161028.0.f51c127/rate/rate.go --- golang-golang-x-time-0.0~git20160202.0.a4bde12/rate/rate.go 2016-08-15 00:29:59.000000000 +0000 +++ golang-golang-x-time-0.0~git20161028.0.f51c127/rate/rate.go 2017-03-13 07:53:51.000000000 +0000 @@ -199,9 +199,10 @@ // The Limiter takes this Reservation into account when allowing future events. // ReserveN returns false if n exceeds the Limiter's burst size. // Usage example: -// r, ok := lim.ReserveN(time.Now(), 1) -// if !ok { +// r := lim.ReserveN(time.Now(), 1) +// if !r.OK() { // // Not allowed to act! Did you remember to set lim.burst to be > 0 ? +// return // } // time.Sleep(r.Delay()) // Act() @@ -221,8 +222,9 @@ // WaitN blocks until lim permits n events to happen. // It returns an error if n exceeds the Limiter's burst size, the Context is // canceled, or the expected wait time exceeds the Context's Deadline. +// The burst limit is ignored if the rate limit is Inf. func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) { - if n > lim.burst { + if n > lim.burst && lim.limit != Inf { return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, lim.burst) } // Check if ctx is already cancelled @@ -281,9 +283,9 @@ // reserveN returns Reservation, not *Reservation, to avoid allocation in AllowN and WaitN. func (lim *Limiter) reserveN(now time.Time, n int, maxFutureReserve time.Duration) Reservation { lim.mu.Lock() - defer lim.mu.Unlock() if lim.limit == Inf { + lim.mu.Unlock() return Reservation{ ok: true, lim: lim, @@ -326,6 +328,7 @@ lim.last = last } + lim.mu.Unlock() return r } diff -Nru golang-golang-x-time-0.0~git20160202.0.a4bde12/rate/rate_test.go golang-golang-x-time-0.0~git20161028.0.f51c127/rate/rate_test.go --- golang-golang-x-time-0.0~git20160202.0.a4bde12/rate/rate_test.go 2016-08-15 00:29:59.000000000 +0000 +++ golang-golang-x-time-0.0~git20161028.0.f51c127/rate/rate_test.go 2017-03-13 07:53:51.000000000 +0000 @@ -396,7 +396,7 @@ cancel() runWait(t, lim, wait{"already-cancelled", ctx, 1, 0, false}) - runWait(t, lim, wait{"n-gt-burst", context.Background(), 4, 0, false}) + runWait(t, lim, wait{"exceed-burst-error", context.Background(), 4, 0, false}) runWait(t, lim, wait{"act-now", context.Background(), 2, 0, true}) runWait(t, lim, wait{"act-later", context.Background(), 3, 2, true}) @@ -425,3 +425,21 @@ runWait(t, lim, wait{"act-now", ctx, 2, 0, true}) runWait(t, lim, wait{"w-timeout-err", ctx, 3, 0, false}) } + +func TestWaitInf(t *testing.T) { + lim := NewLimiter(Inf, 0) + + runWait(t, lim, wait{"exceed-burst-no-error", context.Background(), 3, 0, true}) +} + +func BenchmarkAllowN(b *testing.B) { + lim := NewLimiter(Every(1*time.Second), 1) + now := time.Now() + b.ReportAllocs() + b.ResetTimer() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + lim.AllowN(now, 1) + } + }) +}