{"action":"created","issue":{"url":"https://api.github.com/repos/celluloid/celluloid/issues/632","labels_url":"https://api.github.com/repos/celluloid/celluloid/issues/632/labels{/name}","comments_url":"https://api.github.com/repos/celluloid/celluloid/issues/632/comments","events_url":"https://api.github.com/repos/celluloid/celluloid/issues/632/events","html_url":"https://github.com/celluloid/celluloid/issues/632","id":84899370,"number":632,"title":"Select API for multiplexing futures, conditions, etc.","user":{"login":"digitalextremist","id":21095,"avatar_url":"https://avatars.githubusercontent.com/u/21095?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalextremist","html_url":"https://github.com/digitalextremist","followers_url":"https://api.github.com/users/digitalextremist/followers","following_url":"https://api.github.com/users/digitalextremist/following{/other_user}","gists_url":"https://api.github.com/users/digitalextremist/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalextremist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalextremist/subscriptions","organizations_url":"https://api.github.com/users/digitalextremist/orgs","repos_url":"https://api.github.com/users/digitalextremist/repos","events_url":"https://api.github.com/users/digitalextremist/events{/privacy}","received_events_url":"https://api.github.com/users/digitalextremist/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/celluloid/celluloid/labels/draft","name":"draft","color":"eb6420"},{"url":"https://api.github.com/repos/celluloid/celluloid/labels/feature","name":"feature","color":"02e10c"},{"url":"https://api.github.com/repos/celluloid/celluloid/labels/gem","name":"gem","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/celluloid/celluloid/milestones/12","html_url":"https://github.com/celluloid/celluloid/milestones/0.17.5","labels_url":"https://api.github.com/repos/celluloid/celluloid/milestones/12/labels","id":1058910,"number":12,"title":"0.17.5","description":"Fixes to 0.17.0 and regroup on older issues needing resolution before 0.18.0","creator":{"login":"digitalextremist","id":21095,"avatar_url":"https://avatars.githubusercontent.com/u/21095?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalextremist","html_url":"https://github.com/digitalextremist","followers_url":"https://api.github.com/users/digitalextremist/followers","following_url":"https://api.github.com/users/digitalextremist/following{/other_user}","gists_url":"https://api.github.com/users/digitalextremist/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalextremist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalextremist/subscriptions","organizations_url":"https://api.github.com/users/digitalextremist/orgs","repos_url":"https://api.github.com/users/digitalextremist/repos","events_url":"https://api.github.com/users/digitalextremist/events{/privacy}","received_events_url":"https://api.github.com/users/digitalextremist/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":3,"state":"open","created_at":"2015-04-08T18:18:59Z","updated_at":"2015-06-04T04:07:00Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-06-04T04:07:00Z","updated_at":"2015-06-04T08:46:32Z","closed_at":null,"body":"Similarly to how `Celluloid::IO` provides a `Reactor` for evented I/O, `Celluloid` itself needs a \"Reactor\" for handling collections of blocking processes such as `Future.value` and `Condition.wait` ... this allows the calling thread to continue processing when *any* of the blocking processes are available for synchronous  operations to proceed.\r\n\r\nCurrently, all the blocking processes would have to complete, with this primitive example being the most common example:\r\n\r\n```ruby\r\nfutures = [\r\n  Celluloid::Future.new { sleep 8; 3+5 },\r\n  Celluloid::Future.new { sleep 3; 1+2 },\r\n  Celluloid::Future.new { sleep 9; 2+7 },\r\n  Celluloid::Future.new { sleep 5; 2+3 }\r\n]\r\n\r\nfutures.map(&:value).map { |v| puts v }\r\n```\r\n\r\nIn that situation, the output would be:\r\n\r\n```\r\n8\r\n3\r\n9\r\n5\r\n```\r\n\r\nBut with proper multiplexing, it would be:\r\n\r\n```\r\n3\r\n5\r\n8\r\n9\r\n```\r\n\r\nLikely this would involve a `Multiplex` object providing muxing and demuxing. In the example, it would replace `Array` as the object the `Future` set exist in, providing an alternative to `#map`\r\n\r\nAn example of how the above would be rewritten multiplexed after the dust settles:\r\n\r\n```ruby\r\nfutures = Celluloid::Multiplex.new(\r\n  Celluloid::Future.new { sleep 8; 3+5 },\r\n  Celluloid::Future.new { sleep 3; 1+2 },\r\n  Celluloid::Future.new { sleep 9; 2+7 },\r\n  Celluloid::Future.new { sleep 5; 2+3 }\r\n)\r\n\r\nfutures.map(&:value).map { |v| puts v }\r\n```"},"comment":{"url":"https://api.github.com/repos/celluloid/celluloid/issues/comments/108790977","html_url":"https://github.com/celluloid/celluloid/issues/632#issuecomment-108790977","issue_url":"https://api.github.com/repos/celluloid/celluloid/issues/632","id":108790977,"user":{"login":"digitalextremist","id":21095,"avatar_url":"https://avatars.githubusercontent.com/u/21095?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalextremist","html_url":"https://github.com/digitalextremist","followers_url":"https://api.github.com/users/digitalextremist/followers","following_url":"https://api.github.com/users/digitalextremist/following{/other_user}","gists_url":"https://api.github.com/users/digitalextremist/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalextremist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalextremist/subscriptions","organizations_url":"https://api.github.com/users/digitalextremist/orgs","repos_url":"https://api.github.com/users/digitalextremist/repos","events_url":"https://api.github.com/users/digitalextremist/events{/privacy}","received_events_url":"https://api.github.com/users/digitalextremist/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T08:46:32Z","updated_at":"2015-06-04T08:46:32Z","body":"Thanks for the precendent/context. Very interesting.\r\n\r\nWe'll keep `Future` *and* `Condition` in core then? In the Rust example it seems like `Future` and `Condition` would be gems and `Multiplex` would be core... if `select!` is the benchmark.\r\n\r\nSo, and aside on an aside: with Erlang/Rust/Akka being the best sources of precedent, it seems we're continuing in a vein of increasingly seeing Celluloid as more of a Ruby VM, abstracted from the \"actual\" Ruby Engine."}}