{"action":"created","issue":{"url":"https://api.github.com/repos/RuedigerMoeller/kontraktor/issues/31","repository_url":"https://api.github.com/repos/RuedigerMoeller/kontraktor","labels_url":"https://api.github.com/repos/RuedigerMoeller/kontraktor/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/RuedigerMoeller/kontraktor/issues/31/comments","events_url":"https://api.github.com/repos/RuedigerMoeller/kontraktor/issues/31/events","html_url":"https://github.com/RuedigerMoeller/kontraktor/issues/31","id":173940156,"number":31,"title":"Cancellation? (Docs)","user":{"login":"Petikoch","id":9936866,"avatar_url":"https://avatars.githubusercontent.com/u/9936866?v=3","gravatar_id":"","url":"https://api.github.com/users/Petikoch","html_url":"https://github.com/Petikoch","followers_url":"https://api.github.com/users/Petikoch/followers","following_url":"https://api.github.com/users/Petikoch/following{/other_user}","gists_url":"https://api.github.com/users/Petikoch/gists{/gist_id}","starred_url":"https://api.github.com/users/Petikoch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Petikoch/subscriptions","organizations_url":"https://api.github.com/users/Petikoch/orgs","repos_url":"https://api.github.com/users/Petikoch/repos","events_url":"https://api.github.com/users/Petikoch/events{/privacy}","received_events_url":"https://api.github.com/users/Petikoch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-30T06:32:47Z","updated_at":"2016-08-30T13:31:26Z","closed_at":null,"body":"Hi @RuedigerMoeller,\r\n\r\ncongratulations for your work! \r\n\r\nI have a question regarding cancellation with kontraktor. I didn't find anything to this in https://github.com/RuedigerMoeller/kontraktor/wiki/Kontraktor-3 or on the IPromise API.\r\n\r\nHow do I cancel an ongoing async operation?\r\n\r\nSince this is a standard use-case for me, it would be nice to have something about it in the docs.\r\n\r\nBest regards from Switzerland,\r\nPeti"},"comment":{"url":"https://api.github.com/repos/RuedigerMoeller/kontraktor/issues/comments/243439144","html_url":"https://github.com/RuedigerMoeller/kontraktor/issues/31#issuecomment-243439144","issue_url":"https://api.github.com/repos/RuedigerMoeller/kontraktor/issues/31","id":243439144,"user":{"login":"RuedigerMoeller","id":6097932,"avatar_url":"https://avatars.githubusercontent.com/u/6097932?v=3","gravatar_id":"","url":"https://api.github.com/users/RuedigerMoeller","html_url":"https://github.com/RuedigerMoeller","followers_url":"https://api.github.com/users/RuedigerMoeller/followers","following_url":"https://api.github.com/users/RuedigerMoeller/following{/other_user}","gists_url":"https://api.github.com/users/RuedigerMoeller/gists{/gist_id}","starred_url":"https://api.github.com/users/RuedigerMoeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuedigerMoeller/subscriptions","organizations_url":"https://api.github.com/users/RuedigerMoeller/orgs","repos_url":"https://api.github.com/users/RuedigerMoeller/repos","events_url":"https://api.github.com/users/RuedigerMoeller/events{/privacy}","received_events_url":"https://api.github.com/users/RuedigerMoeller/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T13:31:25Z","updated_at":"2016-08-30T13:31:25Z","body":"This could be achieved implementing a simple wrapper which simply ignores a callback in case of cancellation. As kontraktor's promises are potentially remoted, there is no \"real\" cancellation, just ignorance of an incoming result.\r\n\r\n\r\n```java\r\n    public static class CancelablePromise<T> extends Promise<T> {\r\n        volatile boolean cancelled;\r\n\r\n        public CancelablePromise(IPromise<T> original) {\r\n            original.then( (r,e) -> {\r\n                if ( ! cancelled ) {\r\n                    complete(r,e);\r\n                }\r\n            });\r\n        }\r\n\r\n        public void cancel() {\r\n            cancelled = true;\r\n        }\r\n    }\r\n```\r\nyou might use this like\r\n\r\n```CancelablePromise myP = new CancelablePromise( actor.asyncMethod() );```\r\n\r\nnote this is an ad-hoch example, but it should work along the lines of this."}}
{"actor":{"display_login":"RuedigerMoeller"}}