{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/44575745","id":44575745,"diff_hunk":"@@ -28,17 +32,15 @@ private[spark] class JobWaiter[T](\n     resultHandler: (Int, T) => Unit)\n   extends JobListener {\n \n-  private var finishedTasks = 0\n-\n-  // Is the job as a whole finished (succeeded or failed)?\n-  @volatile\n-  private var _jobFinished = totalTasks == 0\n-\n-  def jobFinished: Boolean = _jobFinished\n-\n+  private val finishedTasks = new AtomicInteger(0)\n   // If the job is finished, this will be its result. In the case of 0 task jobs (e.g. zero\n   // partition RDDs), we set the jobResult directly to JobSucceeded.\n-  private var jobResult: JobResult = if (jobFinished) JobSucceeded else null\n+  private val jobPromise : Promise[Unit] =\n+    if (totalTasks == 0) Promise.successful(()) else Promise()\n+\n+  def jobFinished: Boolean = jobPromise.isCompleted\n+\n+  def completionFuture : Future[Unit] = jobPromise.future","path":"core/src/main/scala/org/apache/spark/scheduler/JobWaiter.scala","position":32,"original_position":32,"commit_id":"7f4244da42034e29d35919d911a9603c679657bb","original_commit_id":"7f4244da42034e29d35919d911a9603c679657bb","user":{"login":"andrewor14","id":2133137,"avatar_url":"https://avatars.githubusercontent.com/u/2133137?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewor14","html_url":"https://github.com/andrewor14","followers_url":"https://api.github.com/users/andrewor14/followers","following_url":"https://api.github.com/users/andrewor14/following{/other_user}","gists_url":"https://api.github.com/users/andrewor14/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewor14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewor14/subscriptions","organizations_url":"https://api.github.com/users/andrewor14/orgs","repos_url":"https://api.github.com/users/andrewor14/repos","events_url":"https://api.github.com/users/andrewor14/events{/privacy}","received_events_url":"https://api.github.com/users/andrewor14/received_events","type":"User","site_admin":false},"body":"no space before `:`, here and everywhere","created_at":"2015-11-11T19:37:44Z","updated_at":"2015-11-11T19:37:44Z","html_url":"https://github.com/apache/spark/pull/9264#discussion_r44575745","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/9264","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/44575745"},"html":{"href":"https://github.com/apache/spark/pull/9264#discussion_r44575745"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/9264"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/9264","id":48662740,"html_url":"https://github.com/apache/spark/pull/9264","diff_url":"https://github.com/apache/spark/pull/9264.diff","patch_url":"https://github.com/apache/spark/pull/9264.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/9264","number":9264,"state":"open","locked":false,"title":"[SPARK-9026] Modifications to JobWaiter, FutureAction, and AsyncRDDActions to support non-blocking operation","user":{"login":"reggert","id":1971881,"avatar_url":"https://avatars.githubusercontent.com/u/1971881?v=3","gravatar_id":"","url":"https://api.github.com/users/reggert","html_url":"https://github.com/reggert","followers_url":"https://api.github.com/users/reggert/followers","following_url":"https://api.github.com/users/reggert/following{/other_user}","gists_url":"https://api.github.com/users/reggert/gists{/gist_id}","starred_url":"https://api.github.com/users/reggert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reggert/subscriptions","organizations_url":"https://api.github.com/users/reggert/orgs","repos_url":"https://api.github.com/users/reggert/repos","events_url":"https://api.github.com/users/reggert/events{/privacy}","received_events_url":"https://api.github.com/users/reggert/received_events","type":"User","site_admin":false},"body":"These changes rework the implementations of SimpleFutureAction, ComplexFutureAction, JobWaiter, and AsyncRDDActions such that asynchronous callbacks on the generated Futures NEVER block waiting for a job to complete. A small amount of mutex synchronization is necessary to protect the internal fields that manage cancellation, but these locks are only held very briefly and in practice should almost never cause any blocking to occur. The existing blocking APIs of these classes are retained, but they simply delegate to the underlying non-blocking API and `Await` the results with indefinite timeouts.\r\n\r\nAssociated JIRA ticket: https://issues.apache.org/jira/browse/SPARK-11296\r\n\r\nThis pull request contains all my own original work, which I release to the Spark project under its open source license.","created_at":"2015-10-24T19:03:15Z","updated_at":"2015-11-11T19:37:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3024b3dfea496fd8b76f71244b30f01d3f958094","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/9264/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/9264/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/9264/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/7f4244da42034e29d35919d911a9603c679657bb","head":{"label":"reggert:fix-futureaction","ref":"fix-futureaction","sha":"7f4244da42034e29d35919d911a9603c679657bb","user":{"login":"reggert","id":1971881,"avatar_url":"https://avatars.githubusercontent.com/u/1971881?v=3","gravatar_id":"","url":"https://api.github.com/users/reggert","html_url":"https://github.com/reggert","followers_url":"https://api.github.com/users/reggert/followers","following_url":"https://api.github.com/users/reggert/following{/other_user}","gists_url":"https://api.github.com/users/reggert/gists{/gist_id}","starred_url":"https://api.github.com/users/reggert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reggert/subscriptions","organizations_url":"https://api.github.com/users/reggert/orgs","repos_url":"https://api.github.com/users/reggert/repos","events_url":"https://api.github.com/users/reggert/events{/privacy}","received_events_url":"https://api.github.com/users/reggert/received_events","type":"User","site_admin":false},"repo":{"id":44838167,"name":"spark","full_name":"reggert/spark","owner":{"login":"reggert","id":1971881,"avatar_url":"https://avatars.githubusercontent.com/u/1971881?v=3","gravatar_id":"","url":"https://api.github.com/users/reggert","html_url":"https://github.com/reggert","followers_url":"https://api.github.com/users/reggert/followers","following_url":"https://api.github.com/users/reggert/following{/other_user}","gists_url":"https://api.github.com/users/reggert/gists{/gist_id}","starred_url":"https://api.github.com/users/reggert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reggert/subscriptions","organizations_url":"https://api.github.com/users/reggert/orgs","repos_url":"https://api.github.com/users/reggert/repos","events_url":"https://api.github.com/users/reggert/events{/privacy}","received_events_url":"https://api.github.com/users/reggert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/reggert/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/reggert/spark","forks_url":"https://api.github.com/repos/reggert/spark/forks","keys_url":"https://api.github.com/repos/reggert/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reggert/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reggert/spark/teams","hooks_url":"https://api.github.com/repos/reggert/spark/hooks","issue_events_url":"https://api.github.com/repos/reggert/spark/issues/events{/number}","events_url":"https://api.github.com/repos/reggert/spark/events","assignees_url":"https://api.github.com/repos/reggert/spark/assignees{/user}","branches_url":"https://api.github.com/repos/reggert/spark/branches{/branch}","tags_url":"https://api.github.com/repos/reggert/spark/tags","blobs_url":"https://api.github.com/repos/reggert/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reggert/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reggert/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/reggert/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reggert/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/reggert/spark/languages","stargazers_url":"https://api.github.com/repos/reggert/spark/stargazers","contributors_url":"https://api.github.com/repos/reggert/spark/contributors","subscribers_url":"https://api.github.com/repos/reggert/spark/subscribers","subscription_url":"https://api.github.com/repos/reggert/spark/subscription","commits_url":"https://api.github.com/repos/reggert/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/reggert/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/reggert/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/reggert/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/reggert/spark/contents/{+path}","compare_url":"https://api.github.com/repos/reggert/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reggert/spark/merges","archive_url":"https://api.github.com/repos/reggert/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reggert/spark/downloads","issues_url":"https://api.github.com/repos/reggert/spark/issues{/number}","pulls_url":"https://api.github.com/repos/reggert/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/reggert/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/reggert/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reggert/spark/labels{/name}","releases_url":"https://api.github.com/repos/reggert/spark/releases{/id}","created_at":"2015-10-23T20:58:12Z","updated_at":"2015-10-23T20:58:44Z","pushed_at":"2015-11-11T19:21:58Z","git_url":"git://github.com/reggert/spark.git","ssh_url":"git@github.com:reggert/spark.git","clone_url":"https://github.com/reggert/spark.git","svn_url":"https://github.com/reggert/spark","homepage":null,"size":130756,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"c4e19b3819df4cd7a1c495a00bd2844cf55f4dbd","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-11-11T18:27:47Z","pushed_at":"2015-11-11T19:25:10Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1656384,"stargazers_count":6138,"watchers_count":6138,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5679,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":358,"forks":5679,"open_issues":358,"watchers":6138,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/9264"},"html":{"href":"https://github.com/apache/spark/pull/9264"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/9264"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/9264/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/9264/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/9264/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/7f4244da42034e29d35919d911a9603c679657bb"}}}}