public class TicketBucket
extends java.lang.Object
ApiKey per Region.ApiFactory,
Region,
ApiKey.getTicketBucket(Region)| Modifier and Type | Class and Description |
|---|---|
static class |
TicketBucket.Ticket
Rate control ticket.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getBuffer() |
protected long |
getTime()
Android subclasses can override this to provide a more
Android appropriate method.
|
void |
put(TicketBucket.Ticket... tickets)
Return a set of
TicketBucket.Ticket to the appropriate Bucket(s) |
void |
setBuffer(int buffer,
java.util.concurrent.TimeUnit unit)
Set additional buffer time to wait between valid requests.
|
void |
stall(long delay,
java.util.concurrent.TimeUnit timeUnit) |
TicketBucket.Ticket[] |
take()
Takes a
TicketBucket.Ticket from each Bucket in this semaphore. |
public TicketBucket.Ticket[] take() throws java.lang.InterruptedException
TicketBucket.Ticket from each Bucket in this semaphore.
Blocks until each Bucket yields a TicketBucket.TicketTicketBucket.Ticket from each Bucketjava.lang.InterruptedException - if cancelledpublic void put(TicketBucket.Ticket... tickets) throws java.lang.InterruptedException
TicketBucket.Ticket to the appropriate Bucket(s)tickets - set of TicketBucket.Tickets retrieved using take()java.lang.InterruptedException - if cancelledpublic void setBuffer(int buffer,
java.util.concurrent.TimeUnit unit)
buffer - time bufferunit - time unitpublic long getBuffer()
public void stall(long delay,
java.util.concurrent.TimeUnit timeUnit)
delay - pause this TicketBucket for this many time unitstimeUnit - time unit, usually secondsprotected long getTime()