{"action":"created","issue":{"url":"https://api.github.com/repos/stanfy/goro/issues/4","labels_url":"https://api.github.com/repos/stanfy/goro/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/stanfy/goro/issues/4/comments","events_url":"https://api.github.com/repos/stanfy/goro/issues/4/events","html_url":"https://github.com/stanfy/goro/issues/4","id":94104404,"number":4,"title":"Service binding and scheduling from 'working' thread","user":{"login":"almozavr","id":780153,"avatar_url":"https://avatars.githubusercontent.com/u/780153?v=3","gravatar_id":"","url":"https://api.github.com/users/almozavr","html_url":"https://github.com/almozavr","followers_url":"https://api.github.com/users/almozavr/followers","following_url":"https://api.github.com/users/almozavr/following{/other_user}","gists_url":"https://api.github.com/users/almozavr/gists{/gist_id}","starred_url":"https://api.github.com/users/almozavr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almozavr/subscriptions","organizations_url":"https://api.github.com/users/almozavr/orgs","repos_url":"https://api.github.com/users/almozavr/repos","events_url":"https://api.github.com/users/almozavr/events{/privacy}","received_events_url":"https://api.github.com/users/almozavr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-09T17:12:13Z","updated_at":"2015-07-12T09:30:15Z","closed_at":null,"body":"`BoundGoroImpl` uses `onServiceConnected` which is always called in `MainThread` by Android. In the same time, `schedule(...)` could be called from any thread. And in case `bindOneshot` `onServiceConnected` could be called even before `schedule` puts `future` into `postponed` - in this case, future would never start.\r\n\r\nQuick ugly fix is here https://github.com/almozavr/goro/commit/76a17c82aa9071775e33ed2d80afd0a7cdd4fdb5 - I think it's no good to be merged into library, but I want to start a discussion."},"comment":{"url":"https://api.github.com/repos/stanfy/goro/issues/comments/120703601","html_url":"https://github.com/stanfy/goro/issues/4#issuecomment-120703601","issue_url":"https://api.github.com/repos/stanfy/goro/issues/4","id":120703601,"user":{"login":"almozavr","id":780153,"avatar_url":"https://avatars.githubusercontent.com/u/780153?v=3","gravatar_id":"","url":"https://api.github.com/users/almozavr","html_url":"https://github.com/almozavr","followers_url":"https://api.github.com/users/almozavr/followers","following_url":"https://api.github.com/users/almozavr/following{/other_user}","gists_url":"https://api.github.com/users/almozavr/gists{/gist_id}","starred_url":"https://api.github.com/users/almozavr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/almozavr/subscriptions","organizations_url":"https://api.github.com/users/almozavr/orgs","repos_url":"https://api.github.com/users/almozavr/repos","events_url":"https://api.github.com/users/almozavr/events{/privacy}","received_events_url":"https://api.github.com/users/almozavr/received_events","type":"User","site_admin":false},"created_at":"2015-07-12T09:30:15Z","updated_at":"2015-07-12T09:30:15Z","body":"Yes, but it doesn't save you, because client calls `bind` (which starts `onServiceConnected` in main thread) and only then calls `schedule`.\r\nPossible api-friendly solution could be `bindOneshot` changes:\r\n```\r\n    @Override\r\n    public <T> ObservableFuture<T> bindOneshot(String queueName, Callable<T> task) {      \r\n      synchronized (lock) {\r\n        oneshot = true;\r\n      }\r\n      ObservableFuture<T> future = schedule(queueName, task);\r\n      GoroService.bind(context, BoundGoroImpl.this);\r\n      return future;     \r\n    }\r\n```"}}