{"action":"created","issue":{"url":"https://api.github.com/repos/golang/go/issues/20436","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/20436/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/20436/comments","events_url":"https://api.github.com/repos/golang/go/issues/20436/events","html_url":"https://github.com/golang/go/issues/20436","id":230122637,"number":20436,"title":"x/exp/shiny: allow bounded types for Deque","user":{"login":"dskinner","id":92266,"avatar_url":"https://avatars3.githubusercontent.com/u/92266?v=3","gravatar_id":"","url":"https://api.github.com/users/dskinner","html_url":"https://github.com/dskinner","followers_url":"https://api.github.com/users/dskinner/followers","following_url":"https://api.github.com/users/dskinner/following{/other_user}","gists_url":"https://api.github.com/users/dskinner/gists{/gist_id}","starred_url":"https://api.github.com/users/dskinner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dskinner/subscriptions","organizations_url":"https://api.github.com/users/dskinner/orgs","repos_url":"https://api.github.com/users/dskinner/repos","events_url":"https://api.github.com/users/dskinner/events{/privacy}","received_events_url":"https://api.github.com/users/dskinner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/22","html_url":"https://github.com/golang/go/milestone/22","labels_url":"https://api.github.com/repos/golang/go/milestones/22/labels","id":1067491,"number":22,"title":"Unreleased","description":"Issues that do not affect released Go code and binaries.\r\n","creator":{"login":"rsc","id":104030,"avatar_url":"https://avatars2.githubusercontent.com/u/104030?v=3","gravatar_id":"","url":"https://api.github.com/users/rsc","html_url":"https://github.com/rsc","followers_url":"https://api.github.com/users/rsc/followers","following_url":"https://api.github.com/users/rsc/following{/other_user}","gists_url":"https://api.github.com/users/rsc/gists{/gist_id}","starred_url":"https://api.github.com/users/rsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsc/subscriptions","organizations_url":"https://api.github.com/users/rsc/orgs","repos_url":"https://api.github.com/users/rsc/repos","events_url":"https://api.github.com/users/rsc/events{/privacy}","received_events_url":"https://api.github.com/users/rsc/received_events","type":"User","site_admin":false},"open_issues":709,"closed_issues":904,"state":"open","created_at":"2015-04-14T18:48:22Z","updated_at":"2017-07-04T13:33:24Z","due_on":"2099-12-31T08:00:00Z","closed_at":null},"comments":5,"created_at":"2017-05-20T01:49:23Z","updated_at":"2017-07-06T00:56:23Z","closed_at":null,"body":"Calls to window.NextEvent() and the processing of the returned event all happen in the same goroutine. For paint and size events, this can cause Deque to congest with stale events.\r\n\r\nGiven the generic nature of type Deque, one method of addressing this is to allow declaring certain event types to be bounded, in that only N instances of the given type are ever allowed to exist and for simplicity let's say N=1.\r\n\r\nIn a shiny application, I only ever care about the last size and paint events, but I don't think it's appropriate to fuss over those details during any sort of iteration. If I declare a package level event, I might also want to tell Deque to only store N=1 instances.\r\n\r\nTo address this in an example program I wrote, I copy/pasted widget.RunWindow and inserted a small FIFO that exhausts Deque in a goroutine but only ever stores one instance of size and paint:\r\n\r\nhttps://github.com/dskinner/x/blob/01a0257ede3a13250b22e5328097aa9d1a6911f5/glw/example/glwidget/main.go#L207\r\n\r\nThe above isn't done at great effort as the size and paint events only fire when que is empty. A second implementation tracked what would have been que insert index and on NextEvent, checked each bound type if insert index is zero or decremented, finally delivering an event from que if no bounded was sent (but this was just an example program so I removed this).\r\n\r\nProviding some sort of `func (q *Deque) BoundType(T)` for the simple case of N=1 has a couple ramifications/questions:\r\n\r\n* This is no longer exactly a \"Deque\" as we'd begin dividing into buckets. I don't know if there's a bucket (or otherwise) queue type out there that already addresses what I'm raising, but I'd like to research that or get feedback on that before committing to any sort of proposal.\r\n\r\n* For the specific case I'm suggesting above where only the last event of a given type is ever stored, it is, I suppose, theoretically possible to never receive that event given the right sequence of events if each event takes its rightful place based on its original insert index (and not replace the first instance which would negate this). Regardless, I don't feel it's appropriate to replace the first instance with the last and I'm not sure I really consider this case a practical concern.\r\n\r\nAny feedback and/or thoughts for intention of Deque welcomed.\r\n\r\n@nigeltao "},"comment":{"url":"https://api.github.com/repos/golang/go/issues/comments/313266057","html_url":"https://github.com/golang/go/issues/20436#issuecomment-313266057","issue_url":"https://api.github.com/repos/golang/go/issues/20436","id":313266057,"user":{"login":"dskinner","id":92266,"avatar_url":"https://avatars3.githubusercontent.com/u/92266?v=3","gravatar_id":"","url":"https://api.github.com/users/dskinner","html_url":"https://github.com/dskinner","followers_url":"https://api.github.com/users/dskinner/followers","following_url":"https://api.github.com/users/dskinner/following{/other_user}","gists_url":"https://api.github.com/users/dskinner/gists{/gist_id}","starred_url":"https://api.github.com/users/dskinner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dskinner/subscriptions","organizations_url":"https://api.github.com/users/dskinner/orgs","repos_url":"https://api.github.com/users/dskinner/repos","events_url":"https://api.github.com/users/dskinner/events{/privacy}","received_events_url":"https://api.github.com/users/dskinner/received_events","type":"User","site_admin":false},"created_at":"2017-07-06T00:56:23Z","updated_at":"2017-07-06T00:56:23Z","body":"So in short, I'd enumerate the following issues to be addressed:\r\n\r\n* resolve backlog of `paint.Event`\r\n* update how `size.Event` works so it doesn't contribute to backlog of `paint.Event`\r\n\r\nThis should happen in shiny. I'm otherwise not convinced anything more needs to be done. Resolving those two items would appear to target the goal of an ideal CL:\r\n\r\n* applications can no longer produce the original side effect, or the production of such is counter-intuitive."}}
{"actor":{"display_login":"dskinner"}}