GitHub PullRequestReviewCommentEvent at 2014-11-21 13:06:36
Repository: scalaz
Actor: runarorama
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/scalaz/scalaz/pulls/comments/20713495","id":20713495,"diff_hunk":"@@ -81,8 +78,74 @@ sealed abstract class ActorInstances {\n }\n \n trait ActorFunctions {\n-  def actor[A](handler: A => Unit, onError: Throwable => Unit = ActorUtils.rethrowError)\n+  def actor[A](handler: A => Unit, onError: Throwable => Unit = rethrow)\n               (implicit s: Strategy): Actor[A] = new Actor[A](handler, onError)(s)\n \n   implicit def ToFunctionFromActor[A](a: Actor[A]): A => Unit = a ! _\n+\n+  val rethrow: Throwable => Unit = {\n+    case _: InterruptedException => Thread.currentThread.interrupt()\n+    case e =>\n+      val t = Thread.currentThread\n+      val h = t.getUncaughtExceptionHandler\n+      if (h ne null) h.uncaughtException(t, e)\n+      throw e\n+  }\n+  /**\n+   * Creates a strategy that optimized for actors.\n+   * WARNING: This strategy cannot be used for evaluation of values.\n+   *\n+   * Implementation based on improvements committed to Akka by Viktor Klang:\n+   * https://github.com/akka/akka/pull/16152\n+   *\n+   * @param s an executor service instance\n+   * @return a strategy for actors\n+   */\n+  def strategy(implicit s: ExecutorService) = s match {\n+    case p: scala.concurrent.forkjoin.ForkJoinPool => new Strategy {\n+\n+      import scala.concurrent.forkjoin.ForkJoinTask\n+\n+      def apply[A](a: => A): () => A = {\n+        val t = new ForkJoinTask[Unit] {\n+          def getRawResult: Unit = ()\n+\n+          def setRawResult(unit: Unit): Unit = ()\n+\n+          def exec(): Boolean = {\n+            a\n+            false\n+          }\n+        }\n+        if (ForkJoinTask.getPool eq p) t.fork()\n+        else p.execute(t)\n+        null\n+      }\n+    }\n+    case p: ForkJoinPool => new Strategy {","path":"concurrent/src/main/scala/scalaz/concurrent/Actor.scala","position":100,"original_position":100,"commit_id":"a12e550ef9339a945c5bb22c1f3028acec81c628","original_commit_id":"a12e550ef9339a945c5bb22c1f3028acec81c628","user":{"login":"runarorama","id":130916,"avatar_url":"https://avatars.githubusercontent.com/u/130916?v=3","gravatar_id":"","url":"https://api.github.com/users/runarorama","html_url":"https://github.com/runarorama","followers_url":"https://api.github.com/users/runarorama/followers","following_url":"https://api.github.com/users/runarorama/following{/other_user}","gists_url":"https://api.github.com/users/runarorama/gists{/gist_id}","starred_url":"https://api.github.com/users/runarorama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/runarorama/subscriptions","organizations_url":"https://api.github.com/users/runarorama/orgs","repos_url":"https://api.github.com/users/runarorama/repos","events_url":"https://api.github.com/users/runarorama/events{/privacy}","received_events_url":"https://api.github.com/users/runarorama/received_events","type":"User","site_admin":false},"body":"Seems like there's a lot of copypasta here. Is it not possible to abstract out these similarities?","created_at":"2014-11-21T13:06:36Z","updated_at":"2014-11-21T13:06:36Z","html_url":"https://github.com/scalaz/scalaz/pull/845#discussion_r20713495","pull_request_url":"https://api.github.com/repos/scalaz/scalaz/pulls/845","_links":{"self":{"href":"https://api.github.com/repos/scalaz/scalaz/pulls/comments/20713495"},"html":{"href":"https://github.com/scalaz/scalaz/pull/845#discussion_r20713495"},"pull_request":{"href":"https://api.github.com/repos/scalaz/scalaz/pulls/845"}}},"pull_request":{"url":"https://api.github.com/repos/scalaz/scalaz/pulls/845","id":24488177,"html_url":"https://github.com/scalaz/scalaz/pull/845","diff_url":"https://github.com/scalaz/scalaz/pull/845.diff","patch_url":"https://github.com/scalaz/scalaz/pull/845.patch","issue_url":"https://api.github.com/repos/scalaz/scalaz/issues/845","number":845,"state":"open","locked":false,"title":"Reduce memory footprint of actors, add strategy that optimized for actors","user":{"login":"plokhotnyuk","id":890289,"avatar_url":"https://avatars.githubusercontent.com/u/890289?v=3","gravatar_id":"","url":"https://api.github.com/users/plokhotnyuk","html_url":"https://github.com/plokhotnyuk","followers_url":"https://api.github.com/users/plokhotnyuk/followers","following_url":"https://api.github.com/users/plokhotnyuk/following{/other_user}","gists_url":"https://api.github.com/users/plokhotnyuk/gists{/gist_id}","starred_url":"https://api.github.com/users/plokhotnyuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plokhotnyuk/subscriptions","organizations_url":"https://api.github.com/users/plokhotnyuk/orgs","repos_url":"https://api.github.com/users/plokhotnyuk/repos","events_url":"https://api.github.com/users/plokhotnyuk/events{/privacy}","received_events_url":"https://api.github.com/users/plokhotnyuk/received_events","type":"User","site_admin":false},"body":"Proposed changes and additions:\r\n1. Reduce 40 bytes per actor instance by replacing `val` by `def` in `toEffect` definition.\r\n2. Add strategy that more efficient in submitting actors for execution and handling of uncatched errors fix for Scala's ForkJoinPool while it cannot be used for evaluation of values.\r\n3. Add better handling of uncaught errors and InterruptedException: now they rethown properly + added sending of errors to UncaughtExceptionHandler of thread that by default prints stack trace. \r\n4. Add creation on demand for default strategy, thread factory and executor services to minimize usage of resources.\r\n5. Use default thread factory that creates deamon threads for a naive strategy.","created_at":"2014-11-15T11:42:01Z","updated_at":"2014-11-21T13:06:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79332ff04af9ebc99c4afc43c055c64948756d5f","assignee":null,"milestone":{"url":"https://api.github.com/repos/scalaz/scalaz/milestones/5","labels_url":"https://api.github.com/repos/scalaz/scalaz/milestones/5/labels","id":330618,"number":5,"title":"7.2","description":"","creator":{"login":"larsrh","id":923079,"avatar_url":"https://avatars.githubusercontent.com/u/923079?v=3","gravatar_id":"","url":"https://api.github.com/users/larsrh","html_url":"https://github.com/larsrh","followers_url":"https://api.github.com/users/larsrh/followers","following_url":"https://api.github.com/users/larsrh/following{/other_user}","gists_url":"https://api.github.com/users/larsrh/gists{/gist_id}","starred_url":"https://api.github.com/users/larsrh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsrh/subscriptions","organizations_url":"https://api.github.com/users/larsrh/orgs","repos_url":"https://api.github.com/users/larsrh/repos","events_url":"https://api.github.com/users/larsrh/events{/privacy}","received_events_url":"https://api.github.com/users/larsrh/received_events","type":"User","site_admin":false},"open_issues":35,"closed_issues":49,"state":"open","created_at":"2013-05-09T15:51:51Z","updated_at":"2014-11-19T22:34:33Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/scalaz/scalaz/pulls/845/commits","review_comments_url":"https://api.github.com/repos/scalaz/scalaz/pulls/845/comments","review_comment_url":"https://api.github.com/repos/scalaz/scalaz/pulls/comments/{number}","comments_url":"https://api.github.com/repos/scalaz/scalaz/issues/845/comments","statuses_url":"https://api.github.com/repos/scalaz/scalaz/statuses/a12e550ef9339a945c5bb22c1f3028acec81c628","head":{"label":"plokhotnyuk:series/7.2.x","ref":"series/7.2.x","sha":"a12e550ef9339a945c5bb22c1f3028acec81c628","user":{"login":"plokhotnyuk","id":890289,"avatar_url":"https://avatars.githubusercontent.com/u/890289?v=3","gravatar_id":"","url":"https://api.github.com/users/plokhotnyuk","html_url":"https://github.com/plokhotnyuk","followers_url":"https://api.github.com/users/plokhotnyuk/followers","following_url":"https://api.github.com/users/plokhotnyuk/following{/other_user}","gists_url":"https://api.github.com/users/plokhotnyuk/gists{/gist_id}","starred_url":"https://api.github.com/users/plokhotnyuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plokhotnyuk/subscriptions","organizations_url":"https://api.github.com/users/plokhotnyuk/orgs","repos_url":"https://api.github.com/users/plokhotnyuk/repos","events_url":"https://api.github.com/users/plokhotnyuk/events{/privacy}","received_events_url":"https://api.github.com/users/plokhotnyuk/received_events","type":"User","site_admin":false},"repo":{"id":26674434,"name":"scalaz","full_name":"plokhotnyuk/scalaz","owner":{"login":"plokhotnyuk","id":890289,"avatar_url":"https://avatars.githubusercontent.com/u/890289?v=3","gravatar_id":"","url":"https://api.github.com/users/plokhotnyuk","html_url":"https://github.com/plokhotnyuk","followers_url":"https://api.github.com/users/plokhotnyuk/followers","following_url":"https://api.github.com/users/plokhotnyuk/following{/other_user}","gists_url":"https://api.github.com/users/plokhotnyuk/gists{/gist_id}","starred_url":"https://api.github.com/users/plokhotnyuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/plokhotnyuk/subscriptions","organizations_url":"https://api.github.com/users/plokhotnyuk/orgs","repos_url":"https://api.github.com/users/plokhotnyuk/repos","events_url":"https://api.github.com/users/plokhotnyuk/events{/privacy}","received_events_url":"https://api.github.com/users/plokhotnyuk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/plokhotnyuk/scalaz","description":"An extension to the core Scala library for functional programming.","fork":true,"url":"https://api.github.com/repos/plokhotnyuk/scalaz","forks_url":"https://api.github.com/repos/plokhotnyuk/scalaz/forks","keys_url":"https://api.github.com/repos/plokhotnyuk/scalaz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/plokhotnyuk/scalaz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/plokhotnyuk/scalaz/teams","hooks_url":"https://api.github.com/repos/plokhotnyuk/scalaz/hooks","issue_events_url":"https://api.github.com/repos/plokhotnyuk/scalaz/issues/events{/number}","events_url":"https://api.github.com/repos/plokhotnyuk/scalaz/events","assignees_url":"https://api.github.com/repos/plokhotnyuk/scalaz/assignees{/user}","branches_url":"https://api.github.com/repos/plokhotnyuk/scalaz/branches{/branch}","tags_url":"https://api.github.com/repos/plokhotnyuk/scalaz/tags","blobs_url":"https://api.github.com/repos/plokhotnyuk/scalaz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/plokhotnyuk/scalaz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/plokhotnyuk/scalaz/git/refs{/sha}","trees_url":"https://api.github.com/repos/plokhotnyuk/scalaz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/plokhotnyuk/scalaz/statuses/{sha}","languages_url":"https://api.github.com/repos/plokhotnyuk/scalaz/languages","stargazers_url":"https://api.github.com/repos/plokhotnyuk/scalaz/stargazers","contributors_url":"https://api.github.com/repos/plokhotnyuk/scalaz/contributors","subscribers_url":"https://api.github.com/repos/plokhotnyuk/scalaz/subscribers","subscription_url":"https://api.github.com/repos/plokhotnyuk/scalaz/subscription","commits_url":"https://api.github.com/repos/plokhotnyuk/scalaz/commits{/sha}","git_commits_url":"https://api.github.com/repos/plokhotnyuk/scalaz/git/commits{/sha}","comments_url":"https://api.github.com/repos/plokhotnyuk/scalaz/comments{/number}","issue_comment_url":"https://api.github.com/repos/plokhotnyuk/scalaz/issues/comments/{number}","contents_url":"https://api.github.com/repos/plokhotnyuk/scalaz/contents/{+path}","compare_url":"https://api.github.com/repos/plokhotnyuk/scalaz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/plokhotnyuk/scalaz/merges","archive_url":"https://api.github.com/repos/plokhotnyuk/scalaz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/plokhotnyuk/scalaz/downloads","issues_url":"https://api.github.com/repos/plokhotnyuk/scalaz/issues{/number}","pulls_url":"https://api.github.com/repos/plokhotnyuk/scalaz/pulls{/number}","milestones_url":"https://api.github.com/repos/plokhotnyuk/scalaz/milestones{/number}","notifications_url":"https://api.github.com/repos/plokhotnyuk/scalaz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/plokhotnyuk/scalaz/labels{/name}","releases_url":"https://api.github.com/repos/plokhotnyuk/scalaz/releases{/id}","created_at":"2014-11-15T08:45:29Z","updated_at":"2014-11-20T16:15:45Z","pushed_at":"2014-11-20T16:15:44Z","git_url":"git://github.com/plokhotnyuk/scalaz.git","ssh_url":"git@github.com:plokhotnyuk/scalaz.git","clone_url":"https://github.com/plokhotnyuk/scalaz.git","svn_url":"https://github.com/plokhotnyuk/scalaz","homepage":"http://typelevel.org","size":91750,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"series/7.2.x"}},"base":{"label":"scalaz:series/7.2.x","ref":"series/7.2.x","sha":"059ef21f92b4087dec36756148dda7b0ed91411c","user":{"login":"scalaz","id":183416,"avatar_url":"https://avatars.githubusercontent.com/u/183416?v=3","gravatar_id":"","url":"https://api.github.com/users/scalaz","html_url":"https://github.com/scalaz","followers_url":"https://api.github.com/users/scalaz/followers","following_url":"https://api.github.com/users/scalaz/following{/other_user}","gists_url":"https://api.github.com/users/scalaz/gists{/gist_id}","starred_url":"https://api.github.com/users/scalaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalaz/subscriptions","organizations_url":"https://api.github.com/users/scalaz/orgs","repos_url":"https://api.github.com/users/scalaz/repos","events_url":"https://api.github.com/users/scalaz/events{/privacy}","received_events_url":"https://api.github.com/users/scalaz/received_events","type":"Organization","site_admin":false},"repo":{"id":474633,"name":"scalaz","full_name":"scalaz/scalaz","owner":{"login":"scalaz","id":183416,"avatar_url":"https://avatars.githubusercontent.com/u/183416?v=3","gravatar_id":"","url":"https://api.github.com/users/scalaz","html_url":"https://github.com/scalaz","followers_url":"https://api.github.com/users/scalaz/followers","following_url":"https://api.github.com/users/scalaz/following{/other_user}","gists_url":"https://api.github.com/users/scalaz/gists{/gist_id}","starred_url":"https://api.github.com/users/scalaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scalaz/subscriptions","organizations_url":"https://api.github.com/users/scalaz/orgs","repos_url":"https://api.github.com/users/scalaz/repos","events_url":"https://api.github.com/users/scalaz/events{/privacy}","received_events_url":"https://api.github.com/users/scalaz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scalaz/scalaz","description":"An extension to the core Scala library for functional programming.","fork":false,"url":"https://api.github.com/repos/scalaz/scalaz","forks_url":"https://api.github.com/repos/scalaz/scalaz/forks","keys_url":"https://api.github.com/repos/scalaz/scalaz/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scalaz/scalaz/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scalaz/scalaz/teams","hooks_url":"https://api.github.com/repos/scalaz/scalaz/hooks","issue_events_url":"https://api.github.com/repos/scalaz/scalaz/issues/events{/number}","events_url":"https://api.github.com/repos/scalaz/scalaz/events","assignees_url":"https://api.github.com/repos/scalaz/scalaz/assignees{/user}","branches_url":"https://api.github.com/repos/scalaz/scalaz/branches{/branch}","tags_url":"https://api.github.com/repos/scalaz/scalaz/tags","blobs_url":"https://api.github.com/repos/scalaz/scalaz/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scalaz/scalaz/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scalaz/scalaz/git/refs{/sha}","trees_url":"https://api.github.com/repos/scalaz/scalaz/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scalaz/scalaz/statuses/{sha}","languages_url":"https://api.github.com/repos/scalaz/scalaz/languages","stargazers_url":"https://api.github.com/repos/scalaz/scalaz/stargazers","contributors_url":"https://api.github.com/repos/scalaz/scalaz/contributors","subscribers_url":"https://api.github.com/repos/scalaz/scalaz/subscribers","subscription_url":"https://api.github.com/repos/scalaz/scalaz/subscription","commits_url":"https://api.github.com/repos/scalaz/scalaz/commits{/sha}","git_commits_url":"https://api.github.com/repos/scalaz/scalaz/git/commits{/sha}","comments_url":"https://api.github.com/repos/scalaz/scalaz/comments{/number}","issue_comment_url":"https://api.github.com/repos/scalaz/scalaz/issues/comments/{number}","contents_url":"https://api.github.com/repos/scalaz/scalaz/contents/{+path}","compare_url":"https://api.github.com/repos/scalaz/scalaz/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scalaz/scalaz/merges","archive_url":"https://api.github.com/repos/scalaz/scalaz/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scalaz/scalaz/downloads","issues_url":"https://api.github.com/repos/scalaz/scalaz/issues{/number}","pulls_url":"https://api.github.com/repos/scalaz/scalaz/pulls{/number}","milestones_url":"https://api.github.com/repos/scalaz/scalaz/milestones{/number}","notifications_url":"https://api.github.com/repos/scalaz/scalaz/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scalaz/scalaz/labels{/name}","releases_url":"https://api.github.com/repos/scalaz/scalaz/releases{/id}","created_at":"2010-01-16T06:18:51Z","updated_at":"2014-11-21T08:16:40Z","pushed_at":"2014-11-18T15:09:15Z","git_url":"git://github.com/scalaz/scalaz.git","ssh_url":"git@github.com:scalaz/scalaz.git","clone_url":"https://github.com/scalaz/scalaz.git","svn_url":"https://github.com/scalaz/scalaz","homepage":"http://typelevel.org","size":109158,"stargazers_count":1567,"watchers_count":1567,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":261,"mirror_url":null,"open_issues_count":45,"forks":261,"open_issues":45,"watchers":1567,"default_branch":"series/7.2.x"}},"_links":{"self":{"href":"https://api.github.com/repos/scalaz/scalaz/pulls/845"},"html":{"href":"https://github.com/scalaz/scalaz/pull/845"},"issue":{"href":"https://api.github.com/repos/scalaz/scalaz/issues/845"},"comments":{"href":"https://api.github.com/repos/scalaz/scalaz/issues/845/comments"},"review_comments":{"href":"https://api.github.com/repos/scalaz/scalaz/pulls/845/comments"},"review_comment":{"href":"https://api.github.com/repos/scalaz/scalaz/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/scalaz/scalaz/pulls/845/commits"},"statuses":{"href":"https://api.github.com/repos/scalaz/scalaz/statuses/a12e550ef9339a945c5bb22c1f3028acec81c628"}}}}