You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My app have a dispatchQ(DispatchQueue) for network requests and most other operations, and some other queues for heavy computing. I use PromiseKit like this,
PromiseKit is simple, I just use promise to replace those callbacks. Now I try to use AwaitKit, but soon I find out that await blocks current queue. dispatchQ can never be blocked because while waiting for network responses, the app might doing other small tasks in dispatchQ. I try to create awaitQ for waiting tasks like this,
letawaitQ=DispatchQueue(label:"await")
awaitQ.ak.async{letobjects=tryawait(fetchData())lettasks= let tasks = objects.map{calculate($0 }tryawait(when(fulfilled: tasks))}
However, because dispatchQ have other tasks, awaitQ will still be blocked while waiting for one task. I will try to use DispatchQueue.global(qos: .userInitiated) to start more threads for waiting.
So, what is the best practice for app like this? Is it OK to start lots of threads for await?
The text was updated successfully, but these errors were encountered:
My app have a
dispatchQ
(DispatchQueue) for network requests and most other operations, and some other queues for heavy computing. I use PromiseKit like this,PromiseKit is simple, I just use promise to replace those callbacks. Now I try to use AwaitKit, but soon I find out that
await
blocks current queue.dispatchQ
can never be blocked because while waiting for network responses, the app might doing other small tasks indispatchQ
. I try to createawaitQ
for waiting tasks like this,However, because
dispatchQ
have other tasks,awaitQ
will still be blocked while waiting for one task. I will try to useDispatchQueue.global(qos: .userInitiated)
to start more threads for waiting.So, what is the best practice for app like this? Is it OK to start lots of threads for
await
?The text was updated successfully, but these errors were encountered: