-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Channels #5757
RFC: Channels #5757
Conversation
@amitmurthy Looks like the end of the pull request message got cut off ("Channels will allow...") |
Updated. Thanks. |
The Are these intended to be used between processes, or only between tasks? If the first, I think we should just expand and rename |
They are intended to be used between processes. Let me rework it so that RemoteRefs are defined as |
I don't think we need different types for different channel sizes. |
Does it really make sense to have the queue length in the type? Are we going to dispatch code differently or benefit from different generated code? I'm guessing the only case that might really be different would be |
OK.
|
That makes much more sense to me than having the channel size in the type, although I think the real benefit is probably not dispatching on the element type of the channel but having channels that can only transmit certain kinds of values. (Tangentially related to #5762). |
Neither Channel nor the internal ChannelBuffer that holds the queue are parametric types. Have to add more tests, update doc and possibly implement channel with sz 0, i.e., an unbuffered channel, where a |
On Tue, Feb 11, 2014 at 2:26 PM, Amit Murthy [email protected]:
Why would a Channel specify a pid? Should'nt the design be generic enough
|
It is similar to Typically you would not specify the |
While I think it's fine as a transitional API, I think @ctaf42's point stands – it seems like a fishy API. Why does it make sense for a RemoteRef or a Channel to keep track of which pid owns it? What does it mean to construct a channel owned by a different process than the current one? Under what circumstances would you do such a thing? What happens when a channel gets sent to another machine? Genuine questions here. |
While a Channel gets serialized/deserialized across processes, the underlying ChannelBuffer that it refers to, is never sent anywhere from the machine where it is first created. The Channel object just holds a remote reference to the ChannelBuffer. For example, in a DArray, all the remote references to the local parts point to the respective processes (which created and initialized the local parts). |
This is one reason I would like to keep the |
Ok, that makes sense. We can do that for a while, but it makes sense to only have one name. |
Closing as same functionality has been implemented in package https://github.com/amitmurthy/MUtils.jl |
Considering the discussion in #5511 , this PR implements Channels on top of RemoteRefs.
The channel is a queue of type Any with a size limit. The only operations supported are
put
,take
,fetch
,isready
andwait
. The calls return immediately if the length is within the limit specified at construction time, else they block. If unspecified, the default Channel size is 1000.Introducing Channels on top of RemoteRefs (as opposed to treating RemoteRefs itself as a Channel of size 1), allows us to possibly implement other non-Q messaging idioms in the future.
The
remotecll*
functions only work off RemoteRefs.Channels allow producer and consumer tasks to be independent of each other, and are quite useful as a work distribution queue.