{"action":"created","issue":{"url":"https://api.github.com/repos/BaseXdb/basex/issues/989","labels_url":"https://api.github.com/repos/BaseXdb/basex/issues/989/labels{/name}","comments_url":"https://api.github.com/repos/BaseXdb/basex/issues/989/comments","events_url":"https://api.github.com/repos/BaseXdb/basex/issues/989/events","html_url":"https://github.com/BaseXdb/basex/issues/989","id":42646122,"number":989,"title":"Asynchronous REST calls","user":{"login":"ChristianGruen","id":196589,"avatar_url":"https://avatars.githubusercontent.com/u/196589?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianGruen","html_url":"https://github.com/ChristianGruen","followers_url":"https://api.github.com/users/ChristianGruen/followers","following_url":"https://api.github.com/users/ChristianGruen/following{/other_user}","gists_url":"https://api.github.com/users/ChristianGruen/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianGruen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianGruen/subscriptions","organizations_url":"https://api.github.com/users/ChristianGruen/orgs","repos_url":"https://api.github.com/users/ChristianGruen/repos","events_url":"https://api.github.com/users/ChristianGruen/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianGruen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BaseXdb/basex/labels/feature","name":"feature","color":"f06040"},{"url":"https://api.github.com/repos/BaseXdb/basex/labels/http","name":"http","color":"eeeeee"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2014-09-12T16:25:12Z","updated_at":"2015-10-31T19:18:14Z","closed_at":null,"body":"See http://www.mail-archive.com/basex-talk%40mailman.uni-konstanz.de/msg04405.html\r\n\r\nSolutions provided by other systems:\r\n\r\n* [util:eval-async](http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/util) (eXist-db)\r\n* [asynchronous-jobs](http://www.28.io/documentation/latest/modules/parallelism/asynchronous-jobs) (28msec)\r\n* [xdmp:spawn](http://docs.marklogic.com/xdmp:spawn) (MarkLogic)\r\n"},"comment":{"url":"https://api.github.com/repos/BaseXdb/basex/issues/comments/152765083","html_url":"https://github.com/BaseXdb/basex/issues/989#issuecomment-152765083","issue_url":"https://api.github.com/repos/BaseXdb/basex/issues/989","id":152765083,"user":{"login":"james-jw","id":7120229,"avatar_url":"https://avatars.githubusercontent.com/u/7120229?v=3","gravatar_id":"","url":"https://api.github.com/users/james-jw","html_url":"https://github.com/james-jw","followers_url":"https://api.github.com/users/james-jw/followers","following_url":"https://api.github.com/users/james-jw/following{/other_user}","gists_url":"https://api.github.com/users/james-jw/gists{/gist_id}","starred_url":"https://api.github.com/users/james-jw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/james-jw/subscriptions","organizations_url":"https://api.github.com/users/james-jw/orgs","repos_url":"https://api.github.com/users/james-jw/repos","events_url":"https://api.github.com/users/james-jw/events{/privacy}","received_events_url":"https://api.github.com/users/james-jw/received_events","type":"User","site_admin":false},"created_at":"2015-10-31T19:18:14Z","updated_at":"2015-10-31T19:18:14Z","body":"You could augment the pattern I used and add single method: ``fork`` in addition to the ``fork-join`` that is currently implemented.\r\n\r\nThe difference would be, fork would immediately initiate the process on a new thread and return a promise, which at any time in the future when asked for its value will return the result or block the thread until the result was received. This is slightly different than the queuing approach I showed, as it allows you to manually initiate forks and let the main thread continue while doing the main processing.  Finally, at the end of the main processing the results could be checked using the standard pattern if required.\r\n\r\n```xquery\r\nlet $promise := $promise:fork($someOtherWork) \r\nlet $mainResult :=  (: do processing on main thread :)\r\nreturn\r\n ($mainResult, $promise(()))\r\n```\r\n\r\nAnother difference is the call to the $promise(()) would not strictly required since the forking occurred at the call to ``$fork``. It would only be necessary if you wanted the result.\r\n\r\nNot sure if that covers your case."}}