{"action":"created","issue":{"url":"https://api.github.com/repos/socketry/async/issues/23","repository_url":"https://api.github.com/repos/socketry/async","labels_url":"https://api.github.com/repos/socketry/async/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/socketry/async/issues/23/comments","events_url":"https://api.github.com/repos/socketry/async/issues/23/events","html_url":"https://github.com/socketry/async/issues/23","id":338337185,"node_id":"MDU6SXNzdWUzMzgzMzcxODU=","number":23,"title":"Use Fiber.transfer instead of Fiber.yield","user":{"login":"funny-falcon","id":249427,"node_id":"MDQ6VXNlcjI0OTQyNw==","avatar_url":"https://avatars1.githubusercontent.com/u/249427?v=4","gravatar_id":"","url":"https://api.github.com/users/funny-falcon","html_url":"https://github.com/funny-falcon","followers_url":"https://api.github.com/users/funny-falcon/followers","following_url":"https://api.github.com/users/funny-falcon/following{/other_user}","gists_url":"https://api.github.com/users/funny-falcon/gists{/gist_id}","starred_url":"https://api.github.com/users/funny-falcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/funny-falcon/subscriptions","organizations_url":"https://api.github.com/users/funny-falcon/orgs","repos_url":"https://api.github.com/users/funny-falcon/repos","events_url":"https://api.github.com/users/funny-falcon/events{/privacy}","received_events_url":"https://api.github.com/users/funny-falcon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-07-04T16:52:20Z","updated_at":"2018-07-05T11:47:09Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"`Fiber.yield` is used by Enumerator, so if enumerator will call to some io, it will return to calling fiber instead of being scheduled.\r\nBut if scheduler will use `fiber.transfer`, than it will play nicely with Enumerator."},"comment":{"url":"https://api.github.com/repos/socketry/async/issues/comments/402696328","html_url":"https://github.com/socketry/async/issues/23#issuecomment-402696328","issue_url":"https://api.github.com/repos/socketry/async/issues/23","id":402696328,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMjY5NjMyOA==","user":{"login":"ioquatix","id":30030,"node_id":"MDQ6VXNlcjMwMDMw","avatar_url":"https://avatars1.githubusercontent.com/u/30030?v=4","gravatar_id":"","url":"https://api.github.com/users/ioquatix","html_url":"https://github.com/ioquatix","followers_url":"https://api.github.com/users/ioquatix/followers","following_url":"https://api.github.com/users/ioquatix/following{/other_user}","gists_url":"https://api.github.com/users/ioquatix/gists{/gist_id}","starred_url":"https://api.github.com/users/ioquatix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioquatix/subscriptions","organizations_url":"https://api.github.com/users/ioquatix/orgs","repos_url":"https://api.github.com/users/ioquatix/repos","events_url":"https://api.github.com/users/ioquatix/events{/privacy}","received_events_url":"https://api.github.com/users/ioquatix/received_events","type":"User","site_admin":false},"created_at":"2018-07-05T11:47:09Z","updated_at":"2018-07-05T11:47:09Z","author_association":"MEMBER","body":"It seems like it is possible to emulate `fiber.resume` and `Fiber.yield` using your own \"stack\":\r\n\r\n```ruby\r\n#!/usr/bin/env ruby\r\n\r\nrequire 'fiber'\r\n\r\nmodule Async\r\n\tclass Reactor\r\n\t\tdef initialize\r\n\t\t\t@fiber = nil\r\n\t\tend\r\n\t\t\r\n\t\tdef transfer\r\n\t\t\tfiber = @fiber\r\n\t\t\t@fiber = Fiber.current\r\n\t\t\t\r\n\t\t\tfiber.transfer\r\n\t\tend\r\n\t\t\r\n\t\tdef async(&block)\r\n\t\t\t@fiber = Fiber.current\r\n\t\t\t\r\n\t\t\tFiber.new do\r\n\t\t\t\tblock.call\r\n\t\t\t\t\r\n\t\t\t\t@fiber.transfer\r\n\t\t\tend.transfer\r\n\t\tend\r\n\tend\r\nend\r\n\r\nreactor = Async::Reactor.new\r\n\r\nreactor.async do\r\n\tputs \"Hello World\"\r\n\treactor.async do\r\n\t\tputs \"Goodbye World\"\r\n\t\treactor.transfer\r\n\t\tputs \"I've waited...\"\r\n\tend\r\n\tputs \"Foo Bar\"\r\nend\r\n\r\nputs \"Finished\"\r\n```\r\n\r\nIt prints out\r\n\r\n```\r\nHello World\r\nGoodbye World\r\nFoo Bar\r\nI've waited...\r\nFinished\r\n```\r\n\r\nWhich is the expected order, using `transfer`, but still support nesting yield/resume like semantics."}}
{"actor":{"display_login":"ioquatix"}}