EKFiber is implemented in a fairly heavyweight fashion in terms of NSOperationQueue and GCD semaphores. When a lot of fibers are created and completed within a tight loop, eventually a limit is reached where the system deadlocks. There are usually ~65 blocked operations when the deadlock occurs.
I've done a bunch of refactoring of EKFiber and its callers in this branch. Even moving from the current design (one NSOperationQueue per EKFiber) to a much simplified one (a single global NSOperationQueue for all EKFiber instances) doesn't resolve the problem. So the deadlock seems to be caused by the way semaphores are used to suspend execution.
The real solution is likely going to be switching to a lighter-weight concurrency model based on coroutines. Here are some possibilities I've found after some quick research:
EKFiber
is implemented in a fairly heavyweight fashion in terms ofNSOperationQueue
and GCD semaphores. When a lot of fibers are created and completed within a tight loop, eventually a limit is reached where the system deadlocks. There are usually ~65 blocked operations when the deadlock occurs.I've done a bunch of refactoring of
EKFiber
and its callers in this branch. Even moving from the current design (oneNSOperationQueue
perEKFiber
) to a much simplified one (a single globalNSOperationQueue
for allEKFiber
instances) doesn't resolve the problem. So the deadlock seems to be caused by the way semaphores are used to suspend execution.The real solution is likely going to be switching to a lighter-weight concurrency model based on coroutines. Here are some possibilities I've found after some quick research: