Conversation
|
@conqer Could you please provide a description and a link to a JIRA so we can understand what you're proposing/fixing here? |
f87a03f to
3cdfa02
Compare
3cdfa02 to
1695c98
Compare
|
@adam-mesos, @mpark I have updated the description. |
|
This idea looks cool. 👍 |
|
@haosdent What do you think about the usage difference. Earlier at the call site it used to be: With this change, the interface would be: |
|
@conqer I had a related idea years ago. Some discussion and code can be found here: The goal is slightly different. You want to get rid of those 'dispatch' boilerplate code. My goal is to create a common base class for those libprocess Process wrapper classes so that we don't need to pass raw pointer (or smart pointer) around. It's safe to copy the wrapper class. Looking at your examples, the following code hurts the readability a bit. We'll be having a lot of 'dispatch' calls in the code base, at which moment, people might be asking why not just use the raw dispatch (i.e., dispatch(process, xxx, args...);) instead? If would be cool if we can do the following directly. But I guess it not quite possible. |
|
@jieyu I agree that there is a inconvenience factor in writing "dispatch". The advantage is that you just write the process implementation class (no wrapper) and life cycle management comes for free. I am guessing that writing hundreds of lines of wrapper is more inconvenient. |
|
@conqer It's a trade off, right? User has to use 'dispatch' at very single call site vs. only has one dispatch in the boilerplate code. I personally prefer the second one to simply the call sites. |
|
I see your point about the familiarity of using c++ syntax to call a On Thu, Sep 17, 2015 at 3:26 PM, Jie Yu notifications@github.com wrote:
Jojy G Varghese |
|
If you are OK with using |
|
Couple of reasons:
On Thu, Sep 17, 2015 at 3:56 PM, Jie Yu notifications@github.com wrote:
Jojy G Varghese |
|
Yeah, I think the lifecycle management part is definitely useful. I am just not very convinced about the 'dispatch' part. I could be wrong. Maybe you should ping BenH. |
|
Yes i think it will come down to :
vs
thanks for your feedback. On Thu, Sep 17, 2015 at 4:29 PM, Jie Yu notifications@github.com wrote:
Jojy G Varghese |
|
@conqer Thanks for the summary! I think we all agree that "Automatic life cycle management." is a useful thing to do (as you already did). We can iterate on the "dispatch" primitive later and see what other people think about this. |
|
Wanted to clarify what i meant by representation of dispatch as a higher level construct. Process "Dispatch" is A policy of how a interface can be dispatched. There could be others - say C++11 async or maybe grand central dispatch. The thought is along the lines of policy based designs.
|
|
Closing stale PR. |
Generic Asynchronous Dispatcher
Motivation
Since mesos code is based on the actor model and dispatching an interface
asynchronously is a large part of the code base, generalizing the higher level concept of
asynchronously dispatching an interface would eliminate the need to manually
program the dispatch boilerplate.
An example usage:
For a simple interface like:
Today the developer has to do the following:
a. Write a wrapper class that implements the same interface to add the
dispatching boilerplate.
b. Spend precious time in reviews.
c. Risk introducing bugs.
None of the above steps add any value to the executable binary.
The wrapper class would look like:
At the caller/client site, the code would look like:
Proposal
We should use C++'s rich language semnatics to express the intent and avoid
the boilerplate we write manually.
The basic intent of the code that leads to all the boilerplate above is:
a. An interface that provides a set of functionality.
b. An implementation of the interface.
c. Ability to dispatch that interface asynchronously using actor.
C++ has a rich set of generics that can be used to express above.
Components
ProcessDispatcher
This component will "dispatch" an interface implementation asychronously using
the process framework.
This component can be expressed as:
DispatchInterface
Any interface that provides an implementation that can be "dispatched" can be
expressed using this component.
This component can be expressed as:
Usage:
Collecting the interface in a container
The advantages of using the generic dispatcher:
cycles.