This is an archive of the discontinued LLVM Phabricator instance.

Make TaskQueue support tasks that return values
Needs ReviewPublic

Authored by zturner on Jun 18 2018, 5:23 PM.

Details

Summary

This depends on D48240. After this patch, you will be able to do somethign like

shared_future<int> F = TQ.async([] { return 42; });
shared_future<Error> F2 = TQ.async([] { return someFunctionThatMightFail(); });

Diff Detail

Event Timeline

zturner created this revision.Jun 18 2018, 5:23 PM
labath added inline comments.Jun 19 2018, 1:34 AM
llvm/include/llvm/Support/TaskQueue.h
115–116

This depends a lot on the results of the discussion with Chandler on the other patch, but I was thinking about this possibly long recursion chain caused by these ParentTask links.

I think think we could avoid the recursion if instead of ParentTask->wait(), we did something like TaskQueue->wait(ThisTask.get()). The TaskQueue function would do something like

while (Tasks.front().get() != TaskToWaitFor) Tasks.front()->execute(); // Details about who pops the task TBD
TaskToWaitFor->execute();

The existing wait function would be a special case of this one for TaskToWaitFor = Tasks.back().get(). I think this would also allow you to avoid having a shared_ptrs in the task queue (just plain unique_ptr should suffice).

labath resigned from this revision.Jul 19 2018, 7:49 AM