{"action":"created","comment":{"url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/comments/24441931","id":24441931,"diff_hunk":"@@ -0,0 +1,74 @@\n+/*\n+ *  Copyright (c) 2014, Facebook, Inc.\n+ *  All rights reserved.\n+ *\n+ *  This source code is licensed under the BSD-style license found in the\n+ *  LICENSE file in the root directory of this source tree. An additional grant\n+ *  of patent rights can be found in the PATENTS file in the same directory.\n+ *\n+ */\n+package bolts;\n+\n+import java.util.Locale;\n+import java.util.concurrent.CancellationException;\n+\n+/**\n+ * Propagates notification that operations should be canceled.\n+ * <p/>\n+ * Create an instance of {@code CancellationTokenSource} and pass the token returned from\n+ * {@code #getToken()} to the asynchronous operation(s). Call\n+ * {@code CancellationTokenSource#cancel()} to cancel the operations.\n+ * <p/>\n+ * A {@code CancellationToken} can only be cancelled once - it should not be passed to future operations\n+ * once cancelled.\n+ */\n+public class CancellationToken {\n+\n+  private final Object lock = new Object();\n+  private boolean cancellationRequested;\n+\n+  CancellationToken() {\n+  }\n+\n+  /**\n+   * @return {@code true} if the cancellation was requested from the source, {@code false} otherwise.\n+   */\n+  public boolean isCancellationRequested() {\n+    synchronized (lock) {\n+      return cancellationRequested;\n+    }\n+  }\n+\n+  /**\n+   * Throws an exception if the user has a requested this token be cancelled. May be used to stop\n+   * execution of a thread or runnable.\n+   *\n+   * @throws CancellationException\n+   */","path":"Bolts/src/bolts/CancellationToken.java","position":47,"original_position":47,"commit_id":"35ad1cf4e33c62bbe8786687542ab840b3b29aaa","original_commit_id":"35ad1cf4e33c62bbe8786687542ab840b3b29aaa","user":{"login":"grantland","id":277030,"avatar_url":"https://avatars.githubusercontent.com/u/277030?v=3","gravatar_id":"","url":"https://api.github.com/users/grantland","html_url":"https://github.com/grantland","followers_url":"https://api.github.com/users/grantland/followers","following_url":"https://api.github.com/users/grantland/following{/other_user}","gists_url":"https://api.github.com/users/grantland/gists{/gist_id}","starred_url":"https://api.github.com/users/grantland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grantland/subscriptions","organizations_url":"https://api.github.com/users/grantland/orgs","repos_url":"https://api.github.com/users/grantland/repos","events_url":"https://api.github.com/users/grantland/events{/privacy}","received_events_url":"https://api.github.com/users/grantland/received_events","type":"User","site_admin":false},"body":"```java\r\n/**\r\n * @throws CancellationException if this token has had cancellation requested. \r\n * May be used to stop execution of a thread or runnable.\r\n */\r\n```","created_at":"2015-02-10T19:24:15Z","updated_at":"2015-02-10T19:24:15Z","html_url":"https://github.com/BoltsFramework/Bolts-Android/pull/53#discussion_r24441931","pull_request_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/comments/24441931"},"html":{"href":"https://github.com/BoltsFramework/Bolts-Android/pull/53#discussion_r24441931"},"pull_request":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53","id":28819009,"html_url":"https://github.com/BoltsFramework/Bolts-Android/pull/53","diff_url":"https://github.com/BoltsFramework/Bolts-Android/pull/53.diff","patch_url":"https://github.com/BoltsFramework/Bolts-Android/pull/53.patch","issue_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/issues/53","number":53,"state":"open","locked":false,"title":"Task Cancellation","user":{"login":"JosephEarl","id":2513147,"avatar_url":"https://avatars.githubusercontent.com/u/2513147?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephEarl","html_url":"https://github.com/JosephEarl","followers_url":"https://api.github.com/users/JosephEarl/followers","following_url":"https://api.github.com/users/JosephEarl/following{/other_user}","gists_url":"https://api.github.com/users/JosephEarl/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephEarl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephEarl/subscriptions","organizations_url":"https://api.github.com/users/JosephEarl/orgs","repos_url":"https://api.github.com/users/JosephEarl/repos","events_url":"https://api.github.com/users/JosephEarl/events{/privacy}","received_events_url":"https://api.github.com/users/JosephEarl/received_events","type":"User","site_admin":false},"body":"Implement task cancellation as per [Task Cancellation](https://msdn.microsoft.com/en-us/library/dd997396(v=vs.110).aspx).\r\n\r\n* Add CancellationToken and CancellationTokenSource to match [system.threading.cancellationtoken](https://msdn.microsoft.com/en-us/library/system.threading.cancellationtoken(v=vs.110).aspx) and [system.threading.cancellationtokensource](https://msdn.microsoft.com/en-us/library/system.threading.cancellationtokensource(v=vs.110).aspx)\r\n* Add methods to Task that accept CancellationTokens\r\n* Add AppLinkResolver method that accepts CancellationTokens","created_at":"2015-02-06T15:59:28Z","updated_at":"2015-02-10T19:24:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"91f6d61aaeee803d83dd906807a8e51c51674265","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53/commits","review_comments_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53/comments","review_comment_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/comments/{number}","comments_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/issues/53/comments","statuses_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/statuses/35ad1cf4e33c62bbe8786687542ab840b3b29aaa","head":{"label":"JosephEarl:feature/cancellationtoken","ref":"feature/cancellationtoken","sha":"35ad1cf4e33c62bbe8786687542ab840b3b29aaa","user":{"login":"JosephEarl","id":2513147,"avatar_url":"https://avatars.githubusercontent.com/u/2513147?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephEarl","html_url":"https://github.com/JosephEarl","followers_url":"https://api.github.com/users/JosephEarl/followers","following_url":"https://api.github.com/users/JosephEarl/following{/other_user}","gists_url":"https://api.github.com/users/JosephEarl/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephEarl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephEarl/subscriptions","organizations_url":"https://api.github.com/users/JosephEarl/orgs","repos_url":"https://api.github.com/users/JosephEarl/repos","events_url":"https://api.github.com/users/JosephEarl/events{/privacy}","received_events_url":"https://api.github.com/users/JosephEarl/received_events","type":"User","site_admin":false},"repo":{"id":29488292,"name":"Bolts-Android","full_name":"JosephEarl/Bolts-Android","owner":{"login":"JosephEarl","id":2513147,"avatar_url":"https://avatars.githubusercontent.com/u/2513147?v=3","gravatar_id":"","url":"https://api.github.com/users/JosephEarl","html_url":"https://github.com/JosephEarl","followers_url":"https://api.github.com/users/JosephEarl/followers","following_url":"https://api.github.com/users/JosephEarl/following{/other_user}","gists_url":"https://api.github.com/users/JosephEarl/gists{/gist_id}","starred_url":"https://api.github.com/users/JosephEarl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JosephEarl/subscriptions","organizations_url":"https://api.github.com/users/JosephEarl/orgs","repos_url":"https://api.github.com/users/JosephEarl/repos","events_url":"https://api.github.com/users/JosephEarl/events{/privacy}","received_events_url":"https://api.github.com/users/JosephEarl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JosephEarl/Bolts-Android","description":"Bolts is a collection of low-level libraries designed to make developing mobile apps easier.","fork":true,"url":"https://api.github.com/repos/JosephEarl/Bolts-Android","forks_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/forks","keys_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/teams","hooks_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/hooks","issue_events_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/issues/events{/number}","events_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/events","assignees_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/assignees{/user}","branches_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/branches{/branch}","tags_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/tags","blobs_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/languages","stargazers_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/stargazers","contributors_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/contributors","subscribers_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/subscribers","subscription_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/subscription","commits_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/issues/comments/{number}","contents_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/contents/{+path}","compare_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/merges","archive_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/downloads","issues_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/issues{/number}","pulls_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/labels{/name}","releases_url":"https://api.github.com/repos/JosephEarl/Bolts-Android/releases{/id}","created_at":"2015-01-19T19:40:28Z","updated_at":"2015-02-06T13:15:46Z","pushed_at":"2015-02-10T10:13:43Z","git_url":"git://github.com/JosephEarl/Bolts-Android.git","ssh_url":"git@github.com:JosephEarl/Bolts-Android.git","clone_url":"https://github.com/JosephEarl/Bolts-Android.git","svn_url":"https://github.com/JosephEarl/Bolts-Android","homepage":"http://boltsframework.github.io/docs/android","size":479,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"BoltsFramework:master","ref":"master","sha":"664ede5bdf4873dc32da3b83c14b35a01a1b2c2c","user":{"login":"BoltsFramework","id":6530429,"avatar_url":"https://avatars.githubusercontent.com/u/6530429?v=3","gravatar_id":"","url":"https://api.github.com/users/BoltsFramework","html_url":"https://github.com/BoltsFramework","followers_url":"https://api.github.com/users/BoltsFramework/followers","following_url":"https://api.github.com/users/BoltsFramework/following{/other_user}","gists_url":"https://api.github.com/users/BoltsFramework/gists{/gist_id}","starred_url":"https://api.github.com/users/BoltsFramework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BoltsFramework/subscriptions","organizations_url":"https://api.github.com/users/BoltsFramework/orgs","repos_url":"https://api.github.com/users/BoltsFramework/repos","events_url":"https://api.github.com/users/BoltsFramework/events{/privacy}","received_events_url":"https://api.github.com/users/BoltsFramework/received_events","type":"Organization","site_admin":false},"repo":{"id":16368712,"name":"Bolts-Android","full_name":"BoltsFramework/Bolts-Android","owner":{"login":"BoltsFramework","id":6530429,"avatar_url":"https://avatars.githubusercontent.com/u/6530429?v=3","gravatar_id":"","url":"https://api.github.com/users/BoltsFramework","html_url":"https://github.com/BoltsFramework","followers_url":"https://api.github.com/users/BoltsFramework/followers","following_url":"https://api.github.com/users/BoltsFramework/following{/other_user}","gists_url":"https://api.github.com/users/BoltsFramework/gists{/gist_id}","starred_url":"https://api.github.com/users/BoltsFramework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BoltsFramework/subscriptions","organizations_url":"https://api.github.com/users/BoltsFramework/orgs","repos_url":"https://api.github.com/users/BoltsFramework/repos","events_url":"https://api.github.com/users/BoltsFramework/events{/privacy}","received_events_url":"https://api.github.com/users/BoltsFramework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BoltsFramework/Bolts-Android","description":"Bolts is a collection of low-level libraries designed to make developing mobile apps easier.","fork":false,"url":"https://api.github.com/repos/BoltsFramework/Bolts-Android","forks_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/forks","keys_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/teams","hooks_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/hooks","issue_events_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/issues/events{/number}","events_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/events","assignees_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/assignees{/user}","branches_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/branches{/branch}","tags_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/tags","blobs_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/git/refs{/sha}","trees_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/statuses/{sha}","languages_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/languages","stargazers_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/stargazers","contributors_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/contributors","subscribers_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/subscribers","subscription_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/subscription","commits_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/commits{/sha}","git_commits_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/git/commits{/sha}","comments_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/comments{/number}","issue_comment_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/issues/comments/{number}","contents_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/contents/{+path}","compare_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/merges","archive_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/downloads","issues_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/issues{/number}","pulls_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls{/number}","milestones_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/milestones{/number}","notifications_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/labels{/name}","releases_url":"https://api.github.com/repos/BoltsFramework/Bolts-Android/releases{/id}","created_at":"2014-01-30T04:58:14Z","updated_at":"2015-02-10T08:16:52Z","pushed_at":"2015-02-04T19:32:28Z","git_url":"git://github.com/BoltsFramework/Bolts-Android.git","ssh_url":"git@github.com:BoltsFramework/Bolts-Android.git","clone_url":"https://github.com/BoltsFramework/Bolts-Android.git","svn_url":"https://github.com/BoltsFramework/Bolts-Android","homepage":"http://boltsframework.github.io/docs/android","size":905,"stargazers_count":1427,"watchers_count":1427,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":188,"mirror_url":null,"open_issues_count":9,"forks":188,"open_issues":9,"watchers":1427,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53"},"html":{"href":"https://github.com/BoltsFramework/Bolts-Android/pull/53"},"issue":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/issues/53"},"comments":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/BoltsFramework/Bolts-Android/statuses/35ad1cf4e33c62bbe8786687542ab840b3b29aaa"}}}}