{"action":"created","comment":{"url":"https://api.github.com/repos/radargun/radargun/pulls/comments/39030693","id":39030693,"diff_hunk":"@@ -0,0 +1,131 @@\n+package org.radargun.stages.test;\n+\n+import java.lang.reflect.Array;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.concurrent.atomic.AtomicIntegerArray;\n+import java.util.concurrent.atomic.AtomicLongArray;\n+\n+import org.radargun.logging.Log;\n+import org.radargun.logging.LogFactory;\n+import org.radargun.utils.Projections;\n+import org.radargun.utils.TimeService;\n+\n+/**\n+ * Based on provided frequency, returns matching invocation from {@link #next()} or blocks the thread calling it.\n+ *\n+ * @author Radim Vansa &lt;rvansa@redhat.com&gt;\n+ */\n+public class SchedulingSelector<T> {\n+   private final static Log log = LogFactory.getLog(SchedulingSelector.class);\n+   private final static boolean trace = log.isTraceEnabled();\n+   private final int[] invocations;\n+   private final long[] intervals;\n+   private final T[] operations;\n+   private final int numOperations;\n+   private final AtomicLongArray lastIntervals;\n+   private final AtomicIntegerArray todoInvocations;\n+   private volatile int offset;\n+\n+   /**\n+    * @param operations Returned invocations\n+    * @param invocations Number of operations per interval\n+    * @param intervals Size of slot, in milliseconds\n+    */\n+   public SchedulingSelector(T[] operations, int[] invocations, long[] intervals) {\n+      if (operations.length != invocations.length) throw new IllegalArgumentException();\n+      this.operations = operations;\n+      this.invocations = invocations;\n+      this.intervals = intervals;\n+      numOperations = operations.length;\n+      lastIntervals = new AtomicLongArray(numOperations);\n+      todoInvocations = new AtomicIntegerArray(numOperations);\n+   }\n+\n+   /**\n+    * @return\n+    * @throws InterruptedException\n+    */\n+   public T next() throws InterruptedException {\n+      WAIT_LOOP: for (;;) {","path":"core/src/main/java/org/radargun/stages/test/SchedulingSelector.java","position":50,"original_position":50,"commit_id":"91e2b60011ebb4ffc4f30756c5480da8e327268d","original_commit_id":"91e2b60011ebb4ffc4f30756c5480da8e327268d","user":{"login":"rvansa","id":2167869,"avatar_url":"https://avatars.githubusercontent.com/u/2167869?v=3","gravatar_id":"","url":"https://api.github.com/users/rvansa","html_url":"https://github.com/rvansa","followers_url":"https://api.github.com/users/rvansa/followers","following_url":"https://api.github.com/users/rvansa/following{/other_user}","gists_url":"https://api.github.com/users/rvansa/gists{/gist_id}","starred_url":"https://api.github.com/users/rvansa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvansa/subscriptions","organizations_url":"https://api.github.com/users/rvansa/orgs","repos_url":"https://api.github.com/users/rvansa/repos","events_url":"https://api.github.com/users/rvansa/events{/privacy}","received_events_url":"https://api.github.com/users/rvansa/received_events","type":"User","site_admin":false},"body":"(unless it is stuck in the do while loop with atomic updates, but it's unlikely that it will be stuck there for too long).","created_at":"2015-09-09T11:18:45Z","updated_at":"2015-09-09T11:18:45Z","html_url":"https://github.com/radargun/radargun/pull/236#discussion_r39030693","pull_request_url":"https://api.github.com/repos/radargun/radargun/pulls/236","_links":{"self":{"href":"https://api.github.com/repos/radargun/radargun/pulls/comments/39030693"},"html":{"href":"https://github.com/radargun/radargun/pull/236#discussion_r39030693"},"pull_request":{"href":"https://api.github.com/repos/radargun/radargun/pulls/236"}}},"pull_request":{"url":"https://api.github.com/repos/radargun/radargun/pulls/236","id":37435905,"html_url":"https://github.com/radargun/radargun/pull/236","diff_url":"https://github.com/radargun/radargun/pull/236.diff","patch_url":"https://github.com/radargun/radargun/pull/236.patch","issue_url":"https://api.github.com/repos/radargun/radargun/issues/236","number":236,"state":"open","locked":false,"title":"New (and more correct!) way to run tests","user":{"login":"rvansa","id":2167869,"avatar_url":"https://avatars.githubusercontent.com/u/2167869?v=3","gravatar_id":"","url":"https://api.github.com/users/rvansa","html_url":"https://github.com/rvansa","followers_url":"https://api.github.com/users/rvansa/followers","following_url":"https://api.github.com/users/rvansa/following{/other_user}","gists_url":"https://api.github.com/users/rvansa/gists{/gist_id}","starred_url":"https://api.github.com/users/rvansa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvansa/subscriptions","organizations_url":"https://api.github.com/users/rvansa/orgs","repos_url":"https://api.github.com/users/rvansa/repos","events_url":"https://api.github.com/users/rvansa/events{/privacy}","received_events_url":"https://api.github.com/users/rvansa/received_events","type":"User","site_admin":false},"body":"To let you guys know what to expect as soon as my other PRs are merged.","created_at":"2015-06-11T07:30:03Z","updated_at":"2015-09-09T11:18:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"58c1c92ded5d2f00d6c4daa3523706bb51ae13bd","assignee":null,"milestone":{"url":"https://api.github.com/repos/radargun/radargun/milestones/4","html_url":"https://github.com/radargun/radargun/milestones/3.0.0","labels_url":"https://api.github.com/repos/radargun/radargun/milestones/4/labels","id":1160444,"number":4,"title":"3.0.0","description":null,"creator":{"login":"rvansa","id":2167869,"avatar_url":"https://avatars.githubusercontent.com/u/2167869?v=3","gravatar_id":"","url":"https://api.github.com/users/rvansa","html_url":"https://github.com/rvansa","followers_url":"https://api.github.com/users/rvansa/followers","following_url":"https://api.github.com/users/rvansa/following{/other_user}","gists_url":"https://api.github.com/users/rvansa/gists{/gist_id}","starred_url":"https://api.github.com/users/rvansa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvansa/subscriptions","organizations_url":"https://api.github.com/users/rvansa/orgs","repos_url":"https://api.github.com/users/rvansa/repos","events_url":"https://api.github.com/users/rvansa/events{/privacy}","received_events_url":"https://api.github.com/users/rvansa/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":3,"state":"open","created_at":"2015-06-11T14:54:56Z","updated_at":"2015-09-08T09:23:24Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/radargun/radargun/pulls/236/commits","review_comments_url":"https://api.github.com/repos/radargun/radargun/pulls/236/comments","review_comment_url":"https://api.github.com/repos/radargun/radargun/pulls/comments{/number}","comments_url":"https://api.github.com/repos/radargun/radargun/issues/236/comments","statuses_url":"https://api.github.com/repos/radargun/radargun/statuses/91e2b60011ebb4ffc4f30756c5480da8e327268d","head":{"label":"rvansa:t_rebasing","ref":"t_rebasing","sha":"91e2b60011ebb4ffc4f30756c5480da8e327268d","user":{"login":"rvansa","id":2167869,"avatar_url":"https://avatars.githubusercontent.com/u/2167869?v=3","gravatar_id":"","url":"https://api.github.com/users/rvansa","html_url":"https://github.com/rvansa","followers_url":"https://api.github.com/users/rvansa/followers","following_url":"https://api.github.com/users/rvansa/following{/other_user}","gists_url":"https://api.github.com/users/rvansa/gists{/gist_id}","starred_url":"https://api.github.com/users/rvansa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvansa/subscriptions","organizations_url":"https://api.github.com/users/rvansa/orgs","repos_url":"https://api.github.com/users/rvansa/repos","events_url":"https://api.github.com/users/rvansa/events{/privacy}","received_events_url":"https://api.github.com/users/rvansa/received_events","type":"User","site_admin":false},"repo":{"id":5449188,"name":"radargun","full_name":"rvansa/radargun","owner":{"login":"rvansa","id":2167869,"avatar_url":"https://avatars.githubusercontent.com/u/2167869?v=3","gravatar_id":"","url":"https://api.github.com/users/rvansa","html_url":"https://github.com/rvansa","followers_url":"https://api.github.com/users/rvansa/followers","following_url":"https://api.github.com/users/rvansa/following{/other_user}","gists_url":"https://api.github.com/users/rvansa/gists{/gist_id}","starred_url":"https://api.github.com/users/rvansa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rvansa/subscriptions","organizations_url":"https://api.github.com/users/rvansa/orgs","repos_url":"https://api.github.com/users/rvansa/repos","events_url":"https://api.github.com/users/rvansa/events{/privacy}","received_events_url":"https://api.github.com/users/rvansa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rvansa/radargun","description":"The RadarGun benchmarking framework for data grids and distributed caches","fork":true,"url":"https://api.github.com/repos/rvansa/radargun","forks_url":"https://api.github.com/repos/rvansa/radargun/forks","keys_url":"https://api.github.com/repos/rvansa/radargun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rvansa/radargun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rvansa/radargun/teams","hooks_url":"https://api.github.com/repos/rvansa/radargun/hooks","issue_events_url":"https://api.github.com/repos/rvansa/radargun/issues/events{/number}","events_url":"https://api.github.com/repos/rvansa/radargun/events","assignees_url":"https://api.github.com/repos/rvansa/radargun/assignees{/user}","branches_url":"https://api.github.com/repos/rvansa/radargun/branches{/branch}","tags_url":"https://api.github.com/repos/rvansa/radargun/tags","blobs_url":"https://api.github.com/repos/rvansa/radargun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rvansa/radargun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rvansa/radargun/git/refs{/sha}","trees_url":"https://api.github.com/repos/rvansa/radargun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rvansa/radargun/statuses/{sha}","languages_url":"https://api.github.com/repos/rvansa/radargun/languages","stargazers_url":"https://api.github.com/repos/rvansa/radargun/stargazers","contributors_url":"https://api.github.com/repos/rvansa/radargun/contributors","subscribers_url":"https://api.github.com/repos/rvansa/radargun/subscribers","subscription_url":"https://api.github.com/repos/rvansa/radargun/subscription","commits_url":"https://api.github.com/repos/rvansa/radargun/commits{/sha}","git_commits_url":"https://api.github.com/repos/rvansa/radargun/git/commits{/sha}","comments_url":"https://api.github.com/repos/rvansa/radargun/comments{/number}","issue_comment_url":"https://api.github.com/repos/rvansa/radargun/issues/comments{/number}","contents_url":"https://api.github.com/repos/rvansa/radargun/contents/{+path}","compare_url":"https://api.github.com/repos/rvansa/radargun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rvansa/radargun/merges","archive_url":"https://api.github.com/repos/rvansa/radargun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rvansa/radargun/downloads","issues_url":"https://api.github.com/repos/rvansa/radargun/issues{/number}","pulls_url":"https://api.github.com/repos/rvansa/radargun/pulls{/number}","milestones_url":"https://api.github.com/repos/rvansa/radargun/milestones{/number}","notifications_url":"https://api.github.com/repos/rvansa/radargun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rvansa/radargun/labels{/name}","releases_url":"https://api.github.com/repos/rvansa/radargun/releases{/id}","created_at":"2012-08-17T07:19:46Z","updated_at":"2015-04-28T08:30:21Z","pushed_at":"2015-09-01T12:23:39Z","git_url":"git://github.com/rvansa/radargun.git","ssh_url":"git@github.com:rvansa/radargun.git","clone_url":"https://github.com/rvansa/radargun.git","svn_url":"https://github.com/rvansa/radargun","homepage":"","size":6868,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"radargun:master","ref":"master","sha":"147411d2adbf7d82deb222aad8d29ea590b7b9d6","user":{"login":"radargun","id":517796,"avatar_url":"https://avatars.githubusercontent.com/u/517796?v=3","gravatar_id":"","url":"https://api.github.com/users/radargun","html_url":"https://github.com/radargun","followers_url":"https://api.github.com/users/radargun/followers","following_url":"https://api.github.com/users/radargun/following{/other_user}","gists_url":"https://api.github.com/users/radargun/gists{/gist_id}","starred_url":"https://api.github.com/users/radargun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radargun/subscriptions","organizations_url":"https://api.github.com/users/radargun/orgs","repos_url":"https://api.github.com/users/radargun/repos","events_url":"https://api.github.com/users/radargun/events{/privacy}","received_events_url":"https://api.github.com/users/radargun/received_events","type":"Organization","site_admin":false},"repo":{"id":1156136,"name":"radargun","full_name":"radargun/radargun","owner":{"login":"radargun","id":517796,"avatar_url":"https://avatars.githubusercontent.com/u/517796?v=3","gravatar_id":"","url":"https://api.github.com/users/radargun","html_url":"https://github.com/radargun","followers_url":"https://api.github.com/users/radargun/followers","following_url":"https://api.github.com/users/radargun/following{/other_user}","gists_url":"https://api.github.com/users/radargun/gists{/gist_id}","starred_url":"https://api.github.com/users/radargun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radargun/subscriptions","organizations_url":"https://api.github.com/users/radargun/orgs","repos_url":"https://api.github.com/users/radargun/repos","events_url":"https://api.github.com/users/radargun/events{/privacy}","received_events_url":"https://api.github.com/users/radargun/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/radargun/radargun","description":"The RadarGun benchmarking framework for data grids and distributed caches","fork":false,"url":"https://api.github.com/repos/radargun/radargun","forks_url":"https://api.github.com/repos/radargun/radargun/forks","keys_url":"https://api.github.com/repos/radargun/radargun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/radargun/radargun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/radargun/radargun/teams","hooks_url":"https://api.github.com/repos/radargun/radargun/hooks","issue_events_url":"https://api.github.com/repos/radargun/radargun/issues/events{/number}","events_url":"https://api.github.com/repos/radargun/radargun/events","assignees_url":"https://api.github.com/repos/radargun/radargun/assignees{/user}","branches_url":"https://api.github.com/repos/radargun/radargun/branches{/branch}","tags_url":"https://api.github.com/repos/radargun/radargun/tags","blobs_url":"https://api.github.com/repos/radargun/radargun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/radargun/radargun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/radargun/radargun/git/refs{/sha}","trees_url":"https://api.github.com/repos/radargun/radargun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/radargun/radargun/statuses/{sha}","languages_url":"https://api.github.com/repos/radargun/radargun/languages","stargazers_url":"https://api.github.com/repos/radargun/radargun/stargazers","contributors_url":"https://api.github.com/repos/radargun/radargun/contributors","subscribers_url":"https://api.github.com/repos/radargun/radargun/subscribers","subscription_url":"https://api.github.com/repos/radargun/radargun/subscription","commits_url":"https://api.github.com/repos/radargun/radargun/commits{/sha}","git_commits_url":"https://api.github.com/repos/radargun/radargun/git/commits{/sha}","comments_url":"https://api.github.com/repos/radargun/radargun/comments{/number}","issue_comment_url":"https://api.github.com/repos/radargun/radargun/issues/comments{/number}","contents_url":"https://api.github.com/repos/radargun/radargun/contents/{+path}","compare_url":"https://api.github.com/repos/radargun/radargun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/radargun/radargun/merges","archive_url":"https://api.github.com/repos/radargun/radargun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/radargun/radargun/downloads","issues_url":"https://api.github.com/repos/radargun/radargun/issues{/number}","pulls_url":"https://api.github.com/repos/radargun/radargun/pulls{/number}","milestones_url":"https://api.github.com/repos/radargun/radargun/milestones{/number}","notifications_url":"https://api.github.com/repos/radargun/radargun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/radargun/radargun/labels{/name}","releases_url":"https://api.github.com/repos/radargun/radargun/releases{/id}","created_at":"2010-12-10T13:35:42Z","updated_at":"2015-07-22T11:23:16Z","pushed_at":"2015-09-09T10:48:12Z","git_url":"git://github.com/radargun/radargun.git","ssh_url":"git@github.com:radargun/radargun.git","clone_url":"https://github.com/radargun/radargun.git","svn_url":"https://github.com/radargun/radargun","homepage":"http://radargun.github.com/radargun/","size":7778,"stargazers_count":62,"watchers_count":62,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":21,"forks":43,"open_issues":21,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/radargun/radargun/pulls/236"},"html":{"href":"https://github.com/radargun/radargun/pull/236"},"issue":{"href":"https://api.github.com/repos/radargun/radargun/issues/236"},"comments":{"href":"https://api.github.com/repos/radargun/radargun/issues/236/comments"},"review_comments":{"href":"https://api.github.com/repos/radargun/radargun/pulls/236/comments"},"review_comment":{"href":"https://api.github.com/repos/radargun/radargun/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/radargun/radargun/pulls/236/commits"},"statuses":{"href":"https://api.github.com/repos/radargun/radargun/statuses/91e2b60011ebb4ffc4f30756c5480da8e327268d"}}}}