apollo-ios-dev
apollo-ios-dev copied to clipboard
Implement continuation queue in AsyncReadWriteLock
Attempting to fix https://github.com/apollographql/apollo-ios/issues/3613
The current implementation is a spin lock that does have the possibility of deadlocking if the thread pool is exhausted. This PR implements a continuation queue. The actor is no longer continually running await Task.yield() until the lock is available. Instead the current task is suspended and a continuation is stored in a queue. Whenever a write task or all current read tasks complete, the next tasks in the queue are dispatched. This can be either a single next write task, or a series of queued read tasks.
Current unit tests pass, so there should be no functional regression here. But it's difficult to create a unit test that reliably reproduces this issue because it only occurs under heavy loads. I think any unit test that does reproduce this is also likely to have spurious failures due to time outs on slow CI machines.
Deploy Preview for apollo-ios-docc canceled.
| Name | Link |
|---|---|
| Latest commit | 77271cc518ed400a8dee002e427e2421de52ad24 |
| Latest deploy log | https://app.netlify.com/projects/apollo-ios-docc/deploys/69260b8ceb91d700083df5ac |
✅ Docs preview has no changes
The preview was not built because there were no changes.
Build ID: 2f57e1a57b3baf314db7eb18 Build Logs: View logs