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

Deprecate produce-consume #17699

Closed
amitmurthy opened this issue Jul 29, 2016 · 11 comments · Fixed by #19841
Closed

Deprecate produce-consume #17699

amitmurthy opened this issue Jul 29, 2016 · 11 comments · Fixed by #19841
Labels
design Design of APIs or of the language itself io Involving the I/O subsystem: libuv, read, write, etc. parallelism Parallel or distributed computation
Milestone

Comments

@amitmurthy
Copy link
Contributor

amitmurthy commented Jul 29, 2016

We currently have two different methods of inter-task communication. This issue is a reminder to deprecate the produce / consume API and have that similar functionality supported by implementing support for Channel(0), i.e., put!on a channel backed by by a 0-sized buffer will block till the time a matching take! is called.

Edit : Unbuffered channels, i.e., Channel(0) have been implemented.

@kshyatt kshyatt added parallelism Parallel or distributed computation io Involving the I/O subsystem: libuv, read, write, etc. labels Jul 29, 2016
@StefanKarpinski StefanKarpinski added this to the 0.6.0 milestone Aug 1, 2016
@StefanKarpinski
Copy link
Member

We may want to have a bit of a bikeshedding about what we call these operations since they are going to be the One True Inter-Task Communication method.

@StefanKarpinski StefanKarpinski added the design Design of APIs or of the language itself label Aug 1, 2016
@amitmurthy amitmurthy changed the title Deprecate produce-consume and support Channel(0) Deprecate produce-consume Dec 16, 2016
@tkelman
Copy link
Contributor

tkelman commented Dec 29, 2016

is there any work in progress started on this?

@amitmurthy
Copy link
Contributor Author

Not yet.

@StefanKarpinski
Copy link
Member

Any chance of getting this done nowish?

@amitmurthy
Copy link
Contributor Author

Will do.

@amitmurthy
Copy link
Contributor Author

We have a couple of options here.

Option 1 : Deprecate produce, consume and Task iteration in this cycle and remove them completely in the next one. Users should use Channels for inter-task communication for this functionality by explicitly creating them and passing them across tasks.

Option 2 : Deprecate produce and consume as an API only. Support put!(t::Task=current_task(), v) and take!(t::Task=current_task()) as an alternative to existing functionality, including iteration on a Task. Each Task shall be deemed to be associated with an implicit Channel. The associated Channel is automatically closed when the task exits.

I am inclined towards the second option. Any thoughts?

@tkelman
Copy link
Contributor

tkelman commented Jan 3, 2017

what kind of overhead would having an implicit channel for every task add?

@amitmurthy
Copy link
Contributor Author

what kind of overhead would having an implicit channel for every task add?

Minimal. We would associate a Channel with a Task only when put!/take!/Task iteration is performed on a task object for the first time.

@amitmurthy
Copy link
Contributor Author

I implemented Option 2 and was not too happy with the result. While put! and take! are a partial replacement for produce/consume, we were still left with two different means of inter-task communication. Will open a PR with option 1.

@StefanKarpinski
Copy link
Member

What made you unhappy with the result, @amitmurthy? You didn't like the API or the implementation was messy?

@amitmurthy
Copy link
Contributor Author

The implementation was clean. One of the stated reasons for deprecating produce/consume was to not have two different means of inter-task communication. Supporting put! and take! on Task objects negated this aim. Decided it is better to double down on Channels as the only method for inter-task communication.

Channels as an entity distinct from Tasks is Go like.
Sending and Receiving messages to/from tasks is Erlang like.

Opted for the former instead of having both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design of APIs or of the language itself io Involving the I/O subsystem: libuv, read, write, etc. parallelism Parallel or distributed computation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants