{"action":"created","issue":{"url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/345","labels_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/345/labels{/name}","comments_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/345/comments","events_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/345/events","html_url":"https://github.com/unicorn-engine/unicorn/issues/345","id":123896260,"number":345,"title":"Implement callback function for emulation completion","user":{"login":"mattifestation","id":1781087,"avatar_url":"https://avatars.githubusercontent.com/u/1781087?v=3","gravatar_id":"","url":"https://api.github.com/users/mattifestation","html_url":"https://github.com/mattifestation","followers_url":"https://api.github.com/users/mattifestation/followers","following_url":"https://api.github.com/users/mattifestation/following{/other_user}","gists_url":"https://api.github.com/users/mattifestation/gists{/gist_id}","starred_url":"https://api.github.com/users/mattifestation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattifestation/subscriptions","organizations_url":"https://api.github.com/users/mattifestation/orgs","repos_url":"https://api.github.com/users/mattifestation/repos","events_url":"https://api.github.com/users/mattifestation/events{/privacy}","received_events_url":"https://api.github.com/users/mattifestation/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-12-25T19:58:02Z","updated_at":"2015-12-25T22:43:50Z","closed_at":null,"body":"Is there any way you might consider implementing a callback function that fires upon completion or time out of an emulator run?\r\n\r\nSomething along the lines of this function signature:\r\n\r\n`typedef void (*uc_cb_emu_complete_t)(uc_engine *uc, uint32_t status, void *user_data);`\r\n\r\nwhere status refers to a successful completion or a timeout."},"comment":{"url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/comments/167265566","html_url":"https://github.com/unicorn-engine/unicorn/issues/345#issuecomment-167265566","issue_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/345","id":167265566,"user":{"login":"lunixbochs","id":117642,"avatar_url":"https://avatars.githubusercontent.com/u/117642?v=3","gravatar_id":"","url":"https://api.github.com/users/lunixbochs","html_url":"https://github.com/lunixbochs","followers_url":"https://api.github.com/users/lunixbochs/followers","following_url":"https://api.github.com/users/lunixbochs/following{/other_user}","gists_url":"https://api.github.com/users/lunixbochs/gists{/gist_id}","starred_url":"https://api.github.com/users/lunixbochs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lunixbochs/subscriptions","organizations_url":"https://api.github.com/users/lunixbochs/orgs","repos_url":"https://api.github.com/users/lunixbochs/repos","events_url":"https://api.github.com/users/lunixbochs/events{/privacy}","received_events_url":"https://api.github.com/users/lunixbochs/received_events","type":"User","site_admin":false},"created_at":"2015-12-25T22:43:50Z","updated_at":"2015-12-25T22:43:50Z","body":"I did some further reading and it looks like asynchronous callbacks will be handled by a thread pool, so unless I misinterpreted it you can't guarantee callback ordering and a Unicorn callback thus won't help (as it will still be a data race)\r\n\r\nI don't like the idea of adding callbacks that would need to be maintained in every binding unless they're actually necessary, and this duplicates a feature Unicorn already provides (as the return from `emu_start()` will happily provide a synchronization point indicating the end of emulation and the status code), which is why I'm advising against it.\r\n\r\nThe decision is ultimately up to @aquynh but I'm trying to determine if the callback would help at all, let alone be a significant improvement over your other options."}}