{"action":"created","issue":{"url":"https://api.github.com/repos/yannickl/AwaitKit/issues/29","repository_url":"https://api.github.com/repos/yannickl/AwaitKit","labels_url":"https://api.github.com/repos/yannickl/AwaitKit/issues/29/labels{/name}","comments_url":"https://api.github.com/repos/yannickl/AwaitKit/issues/29/comments","events_url":"https://api.github.com/repos/yannickl/AwaitKit/issues/29/events","html_url":"https://github.com/yannickl/AwaitKit/issues/29","id":311466097,"node_id":"MDU6SXNzdWUzMTE0NjYwOTc=","number":29,"title":"Possibility for a deadlock","user":{"login":"gfzabarino","id":1040182,"node_id":"MDQ6VXNlcjEwNDAxODI=","avatar_url":"https://avatars2.githubusercontent.com/u/1040182?v=4","gravatar_id":"","url":"https://api.github.com/users/gfzabarino","html_url":"https://github.com/gfzabarino","followers_url":"https://api.github.com/users/gfzabarino/followers","following_url":"https://api.github.com/users/gfzabarino/following{/other_user}","gists_url":"https://api.github.com/users/gfzabarino/gists{/gist_id}","starred_url":"https://api.github.com/users/gfzabarino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfzabarino/subscriptions","organizations_url":"https://api.github.com/users/gfzabarino/orgs","repos_url":"https://api.github.com/users/gfzabarino/repos","events_url":"https://api.github.com/users/gfzabarino/events{/privacy}","received_events_url":"https://api.github.com/users/gfzabarino/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-05T04:07:11Z","updated_at":"2018-07-28T03:40:39Z","closed_at":null,"author_association":"NONE","body":"Hi! This library looks really great and I'm considering to include it into a new project. However I have a theory question I'd like to get an answer to before doing that. I was wondering if the following scenario was possible:\r\n\r\n1. `async` something, which gets executed in the \"async\" concurrent queue, which runs in thread A.\r\n2. Inside thread A you `await` for something, which locks thread A, and that something runs on thread B.\r\n3. On thread B something else is awaited, which causes thread B to be locked as well, and that something is dispatched to the \"async\" concurrent queue. Then, GCD chooses thread A to run that, either because it ran out of threads from its internal thread pool, or because it assumes it will unlock eventually, continuing with the dispatched block after that happens.\r\n4. Thread B will be awaiting for something that got dispatched to thread A (the last awaited `async` block), but thread A is also awaiting for thread B to resolve its promise. Then there's a deadlock and there's no way of getting out of it.\r\n\r\nThank you in advance, and as I'm sure something like StackOverflow would be better to ask this kind of questions, I also know there's no better person to answer it than the creator of the framework himself."},"comment":{"url":"https://api.github.com/repos/yannickl/AwaitKit/issues/comments/408579844","html_url":"https://github.com/yannickl/AwaitKit/issues/29#issuecomment-408579844","issue_url":"https://api.github.com/repos/yannickl/AwaitKit/issues/29","id":408579844,"node_id":"MDEyOklzc3VlQ29tbWVudDQwODU3OTg0NA==","user":{"login":"langtutheky","id":9475206,"node_id":"MDQ6VXNlcjk0NzUyMDY=","avatar_url":"https://avatars0.githubusercontent.com/u/9475206?v=4","gravatar_id":"","url":"https://api.github.com/users/langtutheky","html_url":"https://github.com/langtutheky","followers_url":"https://api.github.com/users/langtutheky/followers","following_url":"https://api.github.com/users/langtutheky/following{/other_user}","gists_url":"https://api.github.com/users/langtutheky/gists{/gist_id}","starred_url":"https://api.github.com/users/langtutheky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/langtutheky/subscriptions","organizations_url":"https://api.github.com/users/langtutheky/orgs","repos_url":"https://api.github.com/users/langtutheky/repos","events_url":"https://api.github.com/users/langtutheky/events{/privacy}","received_events_url":"https://api.github.com/users/langtutheky/received_events","type":"User","site_admin":false},"created_at":"2018-07-28T03:40:39Z","updated_at":"2018-07-28T03:40:39Z","author_association":"NONE","body":"Yes, the scenario that you described is completely possible. This is especially true for nesting async/wait. The source code use DispatchSemaphore, and call wait(timeout: . distantFuture), which certainly means this library can result in deadlocks. This problem could be mitigated by overloading another method such await(timeout: DispatchTime) to allow customization on how long should the thread be locked for. "}}
{"actor":{"display_login":"langtutheky"}}