{"action":"created","issue":{"url":"https://api.github.com/repos/google/guava/issues/2386","repository_url":"https://api.github.com/repos/google/guava","labels_url":"https://api.github.com/repos/google/guava/issues/2386/labels{/name}","comments_url":"https://api.github.com/repos/google/guava/issues/2386/comments","events_url":"https://api.github.com/repos/google/guava/issues/2386/events","html_url":"https://github.com/google/guava/issues/2386","id":132010378,"number":2386,"title":"Expose RateLimiter.reserveAndGetWaitLength()/reserveEarliestAvailable() to public API","user":{"login":"stevenpelley","id":4468600,"avatar_url":"https://avatars.githubusercontent.com/u/4468600?v=3","gravatar_id":"","url":"https://api.github.com/users/stevenpelley","html_url":"https://github.com/stevenpelley","followers_url":"https://api.github.com/users/stevenpelley/followers","following_url":"https://api.github.com/users/stevenpelley/following{/other_user}","gists_url":"https://api.github.com/users/stevenpelley/gists{/gist_id}","starred_url":"https://api.github.com/users/stevenpelley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevenpelley/subscriptions","organizations_url":"https://api.github.com/users/stevenpelley/orgs","repos_url":"https://api.github.com/users/stevenpelley/repos","events_url":"https://api.github.com/users/stevenpelley/events{/privacy}","received_events_url":"https://api.github.com/users/stevenpelley/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/guava/labels/package:%20concurrent","name":"package: concurrent","color":"207de5"},{"url":"https://api.github.com/repos/google/guava/labels/type:%20addition","name":"type: addition","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-07T20:45:51Z","updated_at":"2016-06-07T00:25:06Z","closed_at":null,"body":"I would like to consume permits and return either the time that the task may continue, or the time that the task must wait before continuing, as opposed to having the thread sleep.  reserveEarliestAvailable() and reserveAndGetWaitLength() are the internal methods, respectively, that provides such functionality.  Relying on the RateLimiter to sleep in order to enforce the rate is intuitive, but makes it harder to compose RateLimiters into other tools.  Additionally exposing methods to \"try\" acquiring, failing if the required delay would be too great, would preserve consistency with the current API.\r\n\r\nUse-cases:\r\n1.  Limiting the rate of asynchronous tasks.  RateLimiter enforces rates by sleeping on the acquiring threads.  I would like to enforce the rate of tasks by instead scheduling them to a ScheduledExecutorService with the delay returned by reserveAndGetWaitLength().  This creates a rate-limited ExecutorService.\r\n2.  RateLimiter with capacity (see #1707).  An alternative to supporting createWithCapacity() is to expose reserveAndGetWaitLength().  If I want a RateLimiter with a burst capacity of B (in time), I can achieve this by sleeping for max(0, reserveAndGetWaitLength(numPermits) - B).\r\n\r\nThe alternatives are to fork or implement my own RateLimiter from scratch, exposing such methods."},"comment":{"url":"https://api.github.com/repos/google/guava/issues/comments/224128163","html_url":"https://github.com/google/guava/issues/2386#issuecomment-224128163","issue_url":"https://api.github.com/repos/google/guava/issues/2386","id":224128163,"user":{"login":"vharuty","id":11695041,"avatar_url":"https://avatars.githubusercontent.com/u/11695041?v=3","gravatar_id":"","url":"https://api.github.com/users/vharuty","html_url":"https://github.com/vharuty","followers_url":"https://api.github.com/users/vharuty/followers","following_url":"https://api.github.com/users/vharuty/following{/other_user}","gists_url":"https://api.github.com/users/vharuty/gists{/gist_id}","starred_url":"https://api.github.com/users/vharuty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vharuty/subscriptions","organizations_url":"https://api.github.com/users/vharuty/orgs","repos_url":"https://api.github.com/users/vharuty/repos","events_url":"https://api.github.com/users/vharuty/events{/privacy}","received_events_url":"https://api.github.com/users/vharuty/received_events","type":"User","site_admin":false},"created_at":"2016-06-07T00:25:06Z","updated_at":"2016-06-07T00:25:06Z","body":"@kluever hi, please let me know what is the status of this issue."}}
{"actor":{"display_login":"vharuty"}}