{"action":"created","issue":{"url":"https://api.github.com/repos/tmontes/ppytty/issues/36","repository_url":"https://api.github.com/repos/tmontes/ppytty","labels_url":"https://api.github.com/repos/tmontes/ppytty/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/tmontes/ppytty/issues/36/comments","events_url":"https://api.github.com/repos/tmontes/ppytty/issues/36/events","html_url":"https://github.com/tmontes/ppytty/issues/36","id":336200406,"node_id":"MDU6SXNzdWUzMzYyMDA0MDY=","number":36,"title":"Kernel trap redesign - Inter-Task Comms + Multiple Wait","user":{"login":"tmontes","id":1912206,"node_id":"MDQ6VXNlcjE5MTIyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/1912206?v=4","gravatar_id":"","url":"https://api.github.com/users/tmontes","html_url":"https://github.com/tmontes","followers_url":"https://api.github.com/users/tmontes/followers","following_url":"https://api.github.com/users/tmontes/following{/other_user}","gists_url":"https://api.github.com/users/tmontes/gists{/gist_id}","starred_url":"https://api.github.com/users/tmontes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmontes/subscriptions","organizations_url":"https://api.github.com/users/tmontes/orgs","repos_url":"https://api.github.com/users/tmontes/repos","events_url":"https://api.github.com/users/tmontes/events{/privacy}","received_events_url":"https://api.github.com/users/tmontes/received_events","type":"User","site_admin":false},"labels":[{"id":973309409,"node_id":"MDU6TGFiZWw5NzMzMDk0MDk=","url":"https://api.github.com/repos/tmontes/ppytty/labels/kernel","name":"kernel","color":"1d76db","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/tmontes/ppytty/milestones/4","html_url":"https://github.com/tmontes/ppytty/milestone/4","labels_url":"https://api.github.com/repos/tmontes/ppytty/milestones/4/labels","id":3455789,"node_id":"MDk6TWlsZXN0b25lMzQ1NTc4OQ==","number":4,"title":"NOW","description":"Issues and Pull Requests that will get attention before any other (this milestone will go away once the code reaches a somewhat stable state).","creator":{"login":"tmontes","id":1912206,"node_id":"MDQ6VXNlcjE5MTIyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/1912206?v=4","gravatar_id":"","url":"https://api.github.com/users/tmontes","html_url":"https://github.com/tmontes","followers_url":"https://api.github.com/users/tmontes/followers","following_url":"https://api.github.com/users/tmontes/following{/other_user}","gists_url":"https://api.github.com/users/tmontes/gists{/gist_id}","starred_url":"https://api.github.com/users/tmontes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmontes/subscriptions","organizations_url":"https://api.github.com/users/tmontes/orgs","repos_url":"https://api.github.com/users/tmontes/repos","events_url":"https://api.github.com/users/tmontes/events{/privacy}","received_events_url":"https://api.github.com/users/tmontes/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":9,"state":"open","created_at":"2018-06-27T12:12:36Z","updated_at":"2018-07-02T10:13:39Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2018-06-27T12:05:01Z","updated_at":"2018-07-02T10:13:39Z","closed_at":"2018-07-02T10:13:39Z","author_association":"OWNER","body":"## Current Status\r\n\r\nExisting traps:\r\n\r\n| Trap | Blocks? | Notes |\r\n| ---- | ------------ | ------ |\r\n| `direct-clear` | No | Direct terminal output. |\r\n| `direct-print` | No | Direct terminal output. |\r\n| `window-create` | No | Create and return a Window. |\r\n| `window-render` | No | Update terminal output. |\r\n| `window-destroy` | No | Destroy Window and update terminal output. |\r\n| `sleep` | Yes | Return after N seconds. |\r\n| `read-key` | Yes | Return byte corresponding to terminal input. |\r\n| `put-key` | No | Pushback byte to other `read-key` waiting tasks. |\r\n| `task-spawn` | No | Create a child Task. |\r\n| `task-destroy` | No | Destroy child Task and all of its children. |\r\n| `task-wait` | Yes | Wait for any child Task completion. |\r\n| `dump-state` | No | Logs kernel state. |\r\n\r\nFuture library design seems to indicate the need for one or more kernel traps to support inter-task communication. This will lead to, at least, one more trap that blocks the calling task (assuming a simple `message-send` / `message-receive` like trap pair).\r\n\r\nThis type of design, while somewhat intuitive, leads to an unnecessary limitation. Waiting/blocking on multiple things:\r\n\r\n* What if one task wants to block, waiting for either a child task termination or 5 seconds?\r\n* What about waiting for either keyboard input or a child task termination or a message from some task?\r\n\r\n\r\n## Possible Solution\r\n\r\n* All Tasks will have an INBOX, where they receive messages.\r\n* There will be two new kernel traps to support inter-task communication:\r\n  * `message-send`: sends a message (any object) to another Task, does not block.\r\n  * `message-wait`: returns the 1st message in the INBOX, or blocks until there is one.\r\n    * Actually returns a `(<sender>, <value>)` tuple where `<sender>` will be the sender Task or `None` if the message is originated from the kernel.\r\n\r\n* Inter-task communication:\r\n  * Only supported between parents and their children.\r\n  * `message-send` takes two arguments: the destination Task and the message.\r\n    * Parents can easily send messages to their children.\r\n    * Children can send messages to their parents by using `None` as the destination Task (or some TBD constant).\r\n\r\n* About waiting for multiple things simultaneously:\r\n  * Currently blocking traps, like `sleep`, `read-key` and `task-wait` will no longer block: they will return some kind of \"request id\" the caller must track.\r\n  * The calling task **must** `message-wait` to confirm their completion: the kernel will send a message to the task once any of the pending requests is completed. Such message will itself be a `(<request-id>, <result>)` so that the waiting task knows what completed.\r\n\r\n* Simpler, blocking variations of the traps can be implemented at a library level.\r\n\r\n\r\nWill certainly need adjustments, but I like the idea of \"async traps\" and a single \"blocking trap\" a lot.\r\n\r\nBroken down this issue into:\r\n* [x] #45 - Implement inter task communication.\r\n* [ ] #46 - Make all traps except `message-wait` non-blocking."},"comment":{"url":"https://api.github.com/repos/tmontes/ppytty/issues/comments/401749915","html_url":"https://github.com/tmontes/ppytty/issues/36#issuecomment-401749915","issue_url":"https://api.github.com/repos/tmontes/ppytty/issues/36","id":401749915,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTc0OTkxNQ==","user":{"login":"tmontes","id":1912206,"node_id":"MDQ6VXNlcjE5MTIyMDY=","avatar_url":"https://avatars2.githubusercontent.com/u/1912206?v=4","gravatar_id":"","url":"https://api.github.com/users/tmontes","html_url":"https://github.com/tmontes","followers_url":"https://api.github.com/users/tmontes/followers","following_url":"https://api.github.com/users/tmontes/following{/other_user}","gists_url":"https://api.github.com/users/tmontes/gists{/gist_id}","starred_url":"https://api.github.com/users/tmontes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmontes/subscriptions","organizations_url":"https://api.github.com/users/tmontes/orgs","repos_url":"https://api.github.com/users/tmontes/repos","events_url":"https://api.github.com/users/tmontes/events{/privacy}","received_events_url":"https://api.github.com/users/tmontes/received_events","type":"User","site_admin":false},"created_at":"2018-07-02T10:13:39Z","updated_at":"2018-07-02T10:13:39Z","author_association":"OWNER","body":"Tracked in #46 which also links back here. Closing."}}
{"actor":{"display_login":"tmontes"}}