{"action":"closed","issue":{"url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/354","repository_url":"https://api.github.com/repos/measurement-kit/measurement-kit","labels_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/354/labels{/name}","comments_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/354/comments","events_url":"https://api.github.com/repos/measurement-kit/measurement-kit/issues/354/events","html_url":"https://github.com/measurement-kit/measurement-kit/issues/354","id":131349024,"number":354,"title":"Transition from DelayedCall to Poller::call_soon()","user":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/measurement-kit/measurement-kit/labels/cleanup","name":"cleanup","color":"fbca04"},{"url":"https://api.github.com/repos/measurement-kit/measurement-kit/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/measurement-kit/measurement-kit/milestones/5","html_url":"https://github.com/measurement-kit/measurement-kit/milestones/release-0.2.0","labels_url":"https://api.github.com/repos/measurement-kit/measurement-kit/milestones/5/labels","id":1413122,"number":5,"title":"release-0.2.0","description":"- jni api for portolan\r\n- sync jni api for ooni\r\n- mlabns client\r\n- https support\r\n- oonib client using https\r\n- geoip support\r\n- api and implementation cleanup for robustness\r\n- fixes","creator":{"login":"bassosimone","id":337298,"avatar_url":"https://avatars.githubusercontent.com/u/337298?v=3","gravatar_id":"","url":"https://api.github.com/users/bassosimone","html_url":"https://github.com/bassosimone","followers_url":"https://api.github.com/users/bassosimone/followers","following_url":"https://api.github.com/users/bassosimone/following{/other_user}","gists_url":"https://api.github.com/users/bassosimone/gists{/gist_id}","starred_url":"https://api.github.com/users/bassosimone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bassosimone/subscriptions","organizations_url":"https://api.github.com/users/bassosimone/orgs","repos_url":"https://api.github.com/users/bassosimone/repos","events_url":"https://api.github.com/users/bassosimone/events{/privacy}","received_events_url":"https://api.github.com/users/bassosimone/received_events","type":"User","site_admin":false},"open_issues":43,"closed_issues":66,"state":"open","created_at":"2015-11-16T08:34:51Z","updated_at":"2016-04-16T18:24:30Z","due_on":"2016-04-14T22:00:00Z","closed_at":null},"comments":1,"created_at":"2016-02-04T13:33:27Z","updated_at":"2016-04-16T18:24:30Z","closed_at":"2016-04-16T18:24:30Z","body":"Add to Poller a new method, `void call_soon(std::function<void()>)` that allows to register a function to be called soon. This can easily be implemented by passing to `event_once()` as opaque pointer a `std::function<void()> *` pointer referencing a copy of the callback passed as argument.\r\n\r\nSimilar functionality already exists as `DelayedCall`. However `DelayedCalls` is an object callback that the programmer must keep alive by storing it in some place. Whereas `call_soon()` is expected to receive a lambda that, in turn, shall keep alive what it needs using its closure.\r\n\r\nThis transition is nice because it reduces the number of objects whose life cycle the programmer shall worry about. Instead lambdas could be coupled with shared smart pointers to simplify life cycle management because you reference via smart pointers objects you need and this keeps them alive.\r\n\r\n- [x] implement `Poller::call_soon()`\r\n- [x] adapt `net` implementation to use `call_soon()`\r\n- [x] adapt `ooni` implementation to use `call_soon()`\r\n- [x] remove `DelayedCall()`\r\n\r\nThis is something to be implemented gradually with first changes appearing in 0.1.3 and subsequent changes to appear in subsequent releases."}}