{"action":"created","issue":{"url":"https://api.github.com/repos/ocsigen/lwt/issues/223","repository_url":"https://api.github.com/repos/ocsigen/lwt","labels_url":"https://api.github.com/repos/ocsigen/lwt/issues/223/labels{/name}","comments_url":"https://api.github.com/repos/ocsigen/lwt/issues/223/comments","events_url":"https://api.github.com/repos/ocsigen/lwt/issues/223/events","html_url":"https://github.com/ocsigen/lwt/pull/223","id":140433093,"number":223,"title":"Add is_closed and closed operations to Lwt_stream","user":{"login":"seliopou","id":25269,"avatar_url":"https://avatars.githubusercontent.com/u/25269?v=3","gravatar_id":"","url":"https://api.github.com/users/seliopou","html_url":"https://github.com/seliopou","followers_url":"https://api.github.com/users/seliopou/followers","following_url":"https://api.github.com/users/seliopou/following{/other_user}","gists_url":"https://api.github.com/users/seliopou/gists{/gist_id}","starred_url":"https://api.github.com/users/seliopou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seliopou/subscriptions","organizations_url":"https://api.github.com/users/seliopou/orgs","repos_url":"https://api.github.com/users/seliopou/repos","events_url":"https://api.github.com/users/seliopou/events{/privacy}","received_events_url":"https://api.github.com/users/seliopou/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2016-03-13T01:04:52Z","updated_at":"2016-05-03T16:59:33Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocsigen/lwt/pulls/223","html_url":"https://github.com/ocsigen/lwt/pull/223","diff_url":"https://github.com/ocsigen/lwt/pull/223.diff","patch_url":"https://github.com/ocsigen/lwt/pull/223.patch"},"body":"Previously, the `Lwt_stream` API provided no reliable way to detect if a stream had been closed. While on_termination notifies the user if the stream is closed in the future, it does not tell the user if the stream was closed in the past.\r\n    \r\nIntroducing the `is_closed` function addresses this problem, allowing the user to detect if a stream has been closed at any point in time using code like the following:\r\n\r\n```ocaml\r\nif Lwt_stream.is_closed stream then\r\n  rest_of_code ()\r\nelse\r\n  Lwt_stream.on_termination rest_of_code\r\n```\r\nAlternative to this pattern, one could use the `Lwt_stream.close` operation to get a thread that will sleep until the stream is closed:\r\n\r\n```ocaml\r\nLwt_stream.closed stream >|= rest_of_code\r\n```\r\n  "},"comment":{"url":"https://api.github.com/repos/ocsigen/lwt/issues/comments/216595479","html_url":"https://github.com/ocsigen/lwt/pull/223#issuecomment-216595479","issue_url":"https://api.github.com/repos/ocsigen/lwt/issues/223","id":216595479,"user":{"login":"seliopou","id":25269,"avatar_url":"https://avatars.githubusercontent.com/u/25269?v=3","gravatar_id":"","url":"https://api.github.com/users/seliopou","html_url":"https://github.com/seliopou","followers_url":"https://api.github.com/users/seliopou/followers","following_url":"https://api.github.com/users/seliopou/following{/other_user}","gists_url":"https://api.github.com/users/seliopou/gists{/gist_id}","starred_url":"https://api.github.com/users/seliopou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seliopou/subscriptions","organizations_url":"https://api.github.com/users/seliopou/orgs","repos_url":"https://api.github.com/users/seliopou/repos","events_url":"https://api.github.com/users/seliopou/events{/privacy}","received_events_url":"https://api.github.com/users/seliopou/received_events","type":"User","site_admin":false},"created_at":"2016-05-03T16:59:33Z","updated_at":"2016-05-03T16:59:33Z","body":"This should be ready to go. The last commit may be controversial, but from my perspective the sensible way to treat those sorts of steams. So please review and discuss if necessary."}}