{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/48862440","id":48862440,"diff_hunk":"@@ -0,0 +1,132 @@\n+/**\n+ * Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com>\n+ */\n+package akka.stream.impl\n+\n+import akka.stream.OverflowStrategy._\n+import akka.stream._\n+import akka.stream.stage._\n+\n+import scala.concurrent.{ Future, Promise }\n+\n+/**\n+ * INTERNAL API\n+ */\n+private[akka] class QueueSource[T](maxBuffer: Int, overflowStrategy: OverflowStrategy) extends GraphStageWithMaterializedValue[SourceShape[T], SourceQueue[T]] {\n+  trait SourceCompletion {\n+    val completion = Promise[Unit]\n+  }\n+\n+  type Offered = Promise[StreamCallbackStatus[Boolean]]\n+\n+  val out = Outlet[T](\"queueSource.out\")\n+  override val shape: SourceShape[T] = SourceShape.of(out)\n+\n+  override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {\n+    val buffer = if (maxBuffer == 0) null else FixedSizeBuffer[T](maxBuffer)\n+    var pendingOffer: Option[(T, Offered)] = None\n+    var pulled = false\n+\n+    val stageLogic = new GraphStageLogic(shape) with CallbackWrapper[(T, Offered)] with SourceCompletion {\n+      def bufferOverflowException = new Fail.BufferOverflowException(s\"Buffer overflow (max capacity was: $maxBuffer)!\")\n+\n+      override def preStart(): Unit = initCallback(callback.invoke)\n+      override def postStop(): Unit = stopCallback {\n+        case (elem, promise) ⇒ promise.failure(new IllegalStateException(\"Stream is terminated. SourceQueue is detached\"))\n+      }\n+\n+      private def enqueueAndSuccess(elem: T, promise: Offered): Unit = {\n+        buffer.enqueue(elem)\n+        promise.success(StreamCallbackStatus.Success(true))\n+      }\n+\n+      private def receiveElem(elem: T, promise: Offered): Unit = {\n+        if (!buffer.isFull) {\n+          enqueueAndSuccess(elem, promise)\n+        } else (overflowStrategy: @unchecked) match {","path":"akka-stream/src/main/scala/akka/stream/impl/Sources.scala","position":46,"original_position":46,"commit_id":"74a99cac70b05e44feb70bb879c433515687f0db","original_commit_id":"74a99cac70b05e44feb70bb879c433515687f0db","user":{"login":"johanandren","id":666915,"avatar_url":"https://avatars.githubusercontent.com/u/666915?v=3","gravatar_id":"","url":"https://api.github.com/users/johanandren","html_url":"https://github.com/johanandren","followers_url":"https://api.github.com/users/johanandren/followers","following_url":"https://api.github.com/users/johanandren/following{/other_user}","gists_url":"https://api.github.com/users/johanandren/gists{/gist_id}","starred_url":"https://api.github.com/users/johanandren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanandren/subscriptions","organizations_url":"https://api.github.com/users/johanandren/orgs","repos_url":"https://api.github.com/users/johanandren/repos","events_url":"https://api.github.com/users/johanandren/events{/privacy}","received_events_url":"https://api.github.com/users/johanandren/received_events","type":"User","site_admin":false},"body":"Why `@unchecked` here are there strategies not covered?","created_at":"2016-01-05T16:20:30Z","updated_at":"2016-01-05T16:20:30Z","html_url":"https://github.com/akka/akka/pull/19296#discussion_r48862440","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/19296","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/48862440"},"html":{"href":"https://github.com/akka/akka/pull/19296#discussion_r48862440"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/19296"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/19296","id":54607345,"html_url":"https://github.com/akka/akka/pull/19296","diff_url":"https://github.com/akka/akka/pull/19296.diff","patch_url":"https://github.com/akka/akka/pull/19296.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/19296","number":19296,"state":"open","locked":false,"title":"Agolubev #18890 polish source.queue","user":{"login":"agolubev","id":461456,"avatar_url":"https://avatars.githubusercontent.com/u/461456?v=3","gravatar_id":"","url":"https://api.github.com/users/agolubev","html_url":"https://github.com/agolubev","followers_url":"https://api.github.com/users/agolubev/followers","following_url":"https://api.github.com/users/agolubev/following{/other_user}","gists_url":"https://api.github.com/users/agolubev/gists{/gist_id}","starred_url":"https://api.github.com/users/agolubev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agolubev/subscriptions","organizations_url":"https://api.github.com/users/agolubev/orgs","repos_url":"https://api.github.com/users/agolubev/repos","events_url":"https://api.github.com/users/agolubev/events{/privacy}","received_events_url":"https://api.github.com/users/agolubev/received_events","type":"User","site_admin":false},"body":"Ref #18890\r\nHave one concern about call async callback when stage is about to close. Is there a mechanism that does not allow to schedule such call when onComplete received?\r\nI mean potentially getAsyncCallback can be called and scheduled right before stage is completed, so scheduled call will never happen","created_at":"2015-12-26T20:59:35Z","updated_at":"2016-01-05T16:20:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fb49dd6799796962635386007747c3d3374545f0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/19296/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/19296/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/19296/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/74a99cac70b05e44feb70bb879c433515687f0db","head":{"label":"agolubev:agolubev-#18890_Polish_Source.queue","ref":"agolubev-#18890_Polish_Source.queue","sha":"74a99cac70b05e44feb70bb879c433515687f0db","user":{"login":"agolubev","id":461456,"avatar_url":"https://avatars.githubusercontent.com/u/461456?v=3","gravatar_id":"","url":"https://api.github.com/users/agolubev","html_url":"https://github.com/agolubev","followers_url":"https://api.github.com/users/agolubev/followers","following_url":"https://api.github.com/users/agolubev/following{/other_user}","gists_url":"https://api.github.com/users/agolubev/gists{/gist_id}","starred_url":"https://api.github.com/users/agolubev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agolubev/subscriptions","organizations_url":"https://api.github.com/users/agolubev/orgs","repos_url":"https://api.github.com/users/agolubev/repos","events_url":"https://api.github.com/users/agolubev/events{/privacy}","received_events_url":"https://api.github.com/users/agolubev/received_events","type":"User","site_admin":false},"repo":{"id":35570392,"name":"akka","full_name":"agolubev/akka","owner":{"login":"agolubev","id":461456,"avatar_url":"https://avatars.githubusercontent.com/u/461456?v=3","gravatar_id":"","url":"https://api.github.com/users/agolubev","html_url":"https://github.com/agolubev","followers_url":"https://api.github.com/users/agolubev/followers","following_url":"https://api.github.com/users/agolubev/following{/other_user}","gists_url":"https://api.github.com/users/agolubev/gists{/gist_id}","starred_url":"https://api.github.com/users/agolubev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agolubev/subscriptions","organizations_url":"https://api.github.com/users/agolubev/orgs","repos_url":"https://api.github.com/users/agolubev/repos","events_url":"https://api.github.com/users/agolubev/events{/privacy}","received_events_url":"https://api.github.com/users/agolubev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/agolubev/akka","description":"Akka Project","fork":true,"url":"https://api.github.com/repos/agolubev/akka","forks_url":"https://api.github.com/repos/agolubev/akka/forks","keys_url":"https://api.github.com/repos/agolubev/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/agolubev/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/agolubev/akka/teams","hooks_url":"https://api.github.com/repos/agolubev/akka/hooks","issue_events_url":"https://api.github.com/repos/agolubev/akka/issues/events{/number}","events_url":"https://api.github.com/repos/agolubev/akka/events","assignees_url":"https://api.github.com/repos/agolubev/akka/assignees{/user}","branches_url":"https://api.github.com/repos/agolubev/akka/branches{/branch}","tags_url":"https://api.github.com/repos/agolubev/akka/tags","blobs_url":"https://api.github.com/repos/agolubev/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/agolubev/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/agolubev/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/agolubev/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/agolubev/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/agolubev/akka/languages","stargazers_url":"https://api.github.com/repos/agolubev/akka/stargazers","contributors_url":"https://api.github.com/repos/agolubev/akka/contributors","subscribers_url":"https://api.github.com/repos/agolubev/akka/subscribers","subscription_url":"https://api.github.com/repos/agolubev/akka/subscription","commits_url":"https://api.github.com/repos/agolubev/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/agolubev/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/agolubev/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/agolubev/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/agolubev/akka/contents/{+path}","compare_url":"https://api.github.com/repos/agolubev/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/agolubev/akka/merges","archive_url":"https://api.github.com/repos/agolubev/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/agolubev/akka/downloads","issues_url":"https://api.github.com/repos/agolubev/akka/issues{/number}","pulls_url":"https://api.github.com/repos/agolubev/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/agolubev/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/agolubev/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/agolubev/akka/labels{/name}","releases_url":"https://api.github.com/repos/agolubev/akka/releases{/id}","created_at":"2015-05-13T19:39:33Z","updated_at":"2015-05-13T19:39:39Z","pushed_at":"2016-01-01T19:23:28Z","git_url":"git://github.com/agolubev/akka.git","ssh_url":"git@github.com:agolubev/akka.git","clone_url":"https://github.com/agolubev/akka.git","svn_url":"https://github.com/agolubev/akka","homepage":"http://akka.io","size":169012,"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":"akka:release-2.3-dev","ref":"release-2.3-dev","sha":"281def753cd9913d448f0149b4c5cb11342e872a","user":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"name":"akka","full_name":"akka/akka","owner":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akka/akka","description":"Akka Project","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","created_at":"2009-02-16T12:51:54Z","updated_at":"2016-01-05T16:06:42Z","pushed_at":"2016-01-05T14:44:53Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":180180,"stargazers_count":4918,"watchers_count":4918,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1494,"mirror_url":null,"open_issues_count":813,"forks":1494,"open_issues":813,"watchers":4918,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/19296"},"html":{"href":"https://github.com/akka/akka/pull/19296"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/19296"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/19296/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/19296/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/19296/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/74a99cac70b05e44feb70bb879c433515687f0db"}}}}