-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Concurrency for all, any, when #36
Comments
Hi @umbri, The thing is ‘all’ and other extensions do not control the order in which the promises get resolved, nor run them either, but just wait for them. There’s even no guarantees if promises passed to ‘all’ will all be resolved on a concurrent queue simultaneously. It totally depends on how you created those promises and on which queue would you invoke the block which will eventually trigger ‘fulfill’ or ‘reject’ with a particular promise. The following discussion may also be helpful: #28 (comment) Let us know if there’s anything still unclear, happy to elaborate. Thanks. |
Hi @shoumikhin Thank you for a quick reply, About my proposal,
How to create Promise like a closure, that will do something after invoke it example: let closure = {
print("I am closure")
}
...
closure() let promise = Promise {
print("I am promise")
}
...
// only now it will be executed
promise.then {
} |
I think something like this will be a nice feature: https://github.com/mxcl/PromiseKit/blob/master/Sources/when.swift#L104 |
I don't think anything like that would be possible, because Promise is an extremely small and simple abstraction. I imagine you could build something more sophisticated on top of it to allow such "cold" subscription. But there're no plans to overcomplicate the existing lib at the moment. |
Proposal:
concurrency : UInt? = nil
forall
,any
,when
ex: Lets say we want to make 1000 async requests, but with concurrency
10
, i think this will be a useful featureThe text was updated successfully, but these errors were encountered: