Skip to content
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

Reassignments to returned cancellables from within async blocks #880

Open
tcard opened this issue Jul 26, 2019 · 2 comments
Open

Reassignments to returned cancellables from within async blocks #880

tcard opened this issue Jul 26, 2019 · 2 comments
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@tcard
Copy link
Contributor

tcard commented Jul 26, 2019

At some points, we're doing the equivalent of this (pseudo-Swift):

func doSomething(callback) -> ARTCancellable {
    let task = someAsyncSubOperation() {
        task = innerAsyncOperation() {
            callback(...)
        }
    }
    return task
}

This won't work as expected. The inner assignment to task won't have any effect, since at that point we will have returned the previous task already.

What we need to do is to propagate a cancel to the top-level task to subtasks somehow. I don't know if there's some way of doing this or we'll have to implement it ourselves.

┆Issue is synchronized with this Jira Bug by Unito

@ricardopereira
Copy link
Contributor

Oh, you're right. I think we have something like that in the Auth request. It's changing the local variable only. Well, we can use pointer to pointer and change the outside one but we need to be careful to not create leaks over the codebase.

@ricardopereira
Copy link
Contributor

Maybe the best is to use some promise library. WDYT?

@mattheworiordan mattheworiordan added the bug Something isn't working. It's clear that this does need to be fixed. label Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

3 participants