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

Create promise from handle #13

Open
billy1380 opened this issue Jan 30, 2015 · 5 comments
Open

Create promise from handle #13

billy1380 opened this issue Jan 30, 2015 · 5 comments

Comments

@billy1380
Copy link
Contributor

I have a generator task that creates a promise then spawns further generator tasks that rely on the same promise but there is no way to share that promised value with the child jobs. I cannot pass it as a job parameter because that will cause the children to wait for the promise.

I cannot also pass the promise and hold onto it when the child jobs are created because promised values are not serialisable.

Ideally I would like to be able to pass the child jobs a handle to the promise and then be able to convert that handle into a PromisedValue when I need it.

@billy1380
Copy link
Contributor Author

I am not sure I explained myself very well so I have submitted a pull request ( #14 )... I suspect it is not correct for merging... but something along those lines

@eschultink
Copy link

+1

although I'm not entirely clear why you don't want the child jobs to wait on the PromisedValue, if indeed they need its value at some point. But I have a similar need to be able to create a PromiseValue from a handle.

Specifically, I'm pulling in a bunch of data from a 3rd party API using a single fetch job. I have other calculation jobs that depend on that data. I want to start the fetch as soon as my user does the OAuth grant giving my app access, as it potentially takes a while. But I don't yet know the exact data ranges that user will want for the calculation, so the fetch job can't trigger the calculation jobs. Hence I want to start the fetch job, get a PromisedValue for its completion, store its handle somewhere, and then use that handle to make my calculation jobs wait until the data fetch is complete before they actually run (or run immediately if it is indeed complete when they're created).

Alternatively, creating a FutureValue from a JobInfo instance (retrieved using a job handle) could also meet my need. But JobInfo.getOutput() provides a value (an Object) only after the job is complete - not a Value<T> that you could use as an input slot to another job.

@billy1380
Copy link
Contributor Author

I need to sort out a bunch of comments and some unit tests for this to go forward, there are no technical obstacles to the changes. I will try to get it done by Monday 11th May 2015.

@aozarov
Copy link
Contributor

aozarov commented May 7, 2015

@billy1380 great, waiting to see your updates.

@eschultink why don't you start the calculation job with and make it depends on a PromisedValue X.
pass the X's handle to your fetch job and fill the promised value once fetch is completed (you can have
more than X promised values to store the ranges that you need for the calculation.

@billy1380
Copy link
Contributor Author

@aozarov Updates are now in, thanks for the patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants