blob: 6bab1850f881edd0eea7f61693f24c81831a3ba3 [file] [log] [blame]
khenaidooab1f7bd2019-11-14 14:00:27 -05001// Copyright 2017 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// +build !go1.7
6
7package rate
8
9import "golang.org/x/net/context"
10
11// Wait is shorthand for WaitN(ctx, 1).
12func (lim *Limiter) Wait(ctx context.Context) (err error) {
13 return lim.waitN(ctx, 1)
14}
15
16// WaitN blocks until lim permits n events to happen.
17// It returns an error if n exceeds the Limiter's burst size, the Context is
18// canceled, or the expected wait time exceeds the Context's Deadline.
19func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) {
20 return lim.waitN(ctx, n)
21}