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

A Re-design of Channel APIs #228

Open
ddmbr opened this issue Jan 23, 2017 · 0 comments
Open

A Re-design of Channel APIs #228

ddmbr opened this issue Jan 23, 2017 · 0 comments
Assignees

Comments

@ddmbr
Copy link
Member

ddmbr commented Jan 23, 2017

Overview

The Channels should have a hierarchy of APIs, with the two most high-level methods in() and out().

in --+-- recv
     |
     +-- post_recv

out -+-- pre_send
     |
     +-- send
     |
     +-- post_send

Details

Second-level primitives

Here's the rationale of the second-level primitives. recv() is for polling mailbox and parsing the incoming messages. post_recv() is for various synchronization and declaring the completion of the receiving process.

pre_send() facilitates aggregation. For example we may want to combine the messages before sending them to network. send() will mainly use LocalMailbox::send(). post_send() declares completion of the sending process (e.g., by using LocalMailbox::send_complete()) and possibly clears the buffers for incoming messages.

Third-level primitives

There is another hierarchy inside recv(), illustrated as follows,

recv -- process_bin_stream -- [recv_callback]

After recv() gets one BinStream, it gets processed by process_bin_stream(). Inside process_bin_stream(), it extracts many messages from one BinStream, and for each message, it invokes the recv_callback() .

One important point here is that, while all other methods are presented in the ChannelBase, the recv_callback() is optional, and it's application-specific. In another word, it may have different signatures in different types of channels. It should be implemented as a std::function so that it can be replaced during runtime.

According modification in other components

In order to simplify things, channels should no longer get registered in ObjList. list_exec should always take four arguments.

ddmbr added a commit to ddmbr/husky that referenced this issue Jan 24, 2017
ddmbr added a commit to ddmbr/husky that referenced this issue Jan 24, 2017
ddmbr added a commit to ddmbr/husky that referenced this issue Jan 25, 2017
ClydeZhao added a commit to ClydeZhao/husky that referenced this issue Feb 7, 2017
Add unit tests for broadcast channel and migrate channel
ref husky-team#228
ddmbr pushed a commit to ddmbr/husky that referenced this issue Feb 8, 2017
* [Core][Channel] refactor migrate channel

* [Core][Channel] Refactor BroadcastChannel
Add unit tests for broadcast channel and migrate channel
ref husky-team#228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants