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

Proposal: wait/fetch on Task #25928

Closed
iamed2 opened this issue Feb 7, 2018 · 2 comments
Closed

Proposal: wait/fetch on Task #25928

iamed2 opened this issue Feb 7, 2018 · 2 comments
Labels
domain:parallelism Parallel or distributed computation

Comments

@iamed2
Copy link
Contributor

iamed2 commented Feb 7, 2018

Right now wait has the same meaning for almost everything: wait for something to be available or for something to happen. With Task, it means the above plus get a result. For AbstractRemoteRef, this is what fetch does.

I propose moving that functionality of Task to fetch. Here's what it would look like in 0.7:

function fetch(t::Task)
    if !istaskdone(t)
        if t.donenotify === nothing
            t.donenotify = Condition()
        end
    end
    while !istaskdone(t)
        wait(t.donenotify)
    end
    if istaskfailed(t)
        throw(t.exception)
    end
    return task_result(t)
end

@deprecate wait(t::Task) fetch(t)

and in 1.0:

function wait(t::Task)
    if !istaskdone(t)
        if t.donenotify === nothing
            t.donenotify = Condition()
        end
    end
    while !istaskdone(t)
        wait(t.donenotify)
    end
    if istaskfailed(t)
        throw(t.exception)
    end
end

function fetch(t::Task)
    wait(t::Task)
    return task_result(t)
end

How does this sound?

If this is not accepted I would still like to define fetch(t::Task) = wait(t), as it has a clear meaning and allows Tasks and Futures to be used interchangeably in some cases.

@JeffBezanson JeffBezanson added the status:triage This should be discussed on a triage call label Feb 7, 2018
@ararslan ararslan added the domain:parallelism Parallel or distributed computation label Feb 7, 2018
@iamed2
Copy link
Contributor Author

iamed2 commented Feb 7, 2018

Working on a PR now

@JeffBezanson
Copy link
Sponsor Member

Triage accepts.

@JeffBezanson JeffBezanson removed the status:triage This should be discussed on a triage call label Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:parallelism Parallel or distributed computation
Projects
None yet
Development

No branches or pull requests

3 participants