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

Support for commands in parallel #85

Merged
merged 15 commits into from
Sep 26, 2017
Merged

Conversation

julianoes
Copy link
Collaborator

This is a big refactor of the MavlinkCommands class in order to support
multiple commands in parallel. It won't do multiple commands with the
same command ID at the same time in order to prevent conflicts/races
with acks that can't be assigned uniquely.

This is a simple wrapper around std::list to make it thread safe.
The wrapper only implements a small subset of the features of
std::list.
This adds some completion and errors/warnings for vim with the
YouCompleteMe plugin.
ag (the-silver-searcher) did not ignore the directories specified in
gitignore presumably because they were wrong.
This allows to change the timeout time of an existing (running) timeout.
This is a big refactor of the MavlinkCommands class in order to support
multiple commands in parallel. It won't do multiple commands with the
same command ID at the same time in order to prevent conflicts/races
with acks that can't be assigned uniquely.
@julianoes julianoes requested a review from darioxz September 21, 2017 15:09
@@ -0,0 +1,206 @@
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See YouCompleteMe

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 what?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly - what!!

The text says "This file is NOT licensed under the GPLv3, which is the license for the rest of YouCompleteMe."

That looks like a placeholder to me.

And it should be obvious I am not actually reviewing this - I just wanted to see what the code looked like :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove it and say it is licensed as BSD 3-clause like the rest of the repo.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this file says it is public domain, so I'm not sure what I should do.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was our file. If YouComleteMe is an actual real name of a product called YouCompleteMe then we have to leave that alone - it isn't ours to modify.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this file was copied from the YouCompleteMe project, we should leave as is

@julianoes julianoes requested a review from mrpollo September 22, 2017 13:26
@@ -101,6 +102,7 @@ class LogDetailed
std::cout << "|Debug] ";
break;
case LogLevel::Info:
std::cout << ANSI_COLOR_BLUE;
Copy link
Contributor

@darioxz darioxz Sep 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really not critical, but #86 should get merged before #85

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is #86 rebased on to of #85?, can we remove this so we can merge w/o blocking?

Copy link
Member

@mrpollo mrpollo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, I just have a few comments

@@ -101,6 +102,7 @@ class LogDetailed
std::cout << "|Debug] ";
break;
case LogLevel::Info:
std::cout << ANSI_COLOR_BLUE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is #86 rebased on to of #85?, can we remove this so we can merge w/o blocking?

class iterator: public std::list<T>::iterator
{
public:
iterator(typename std::list<T>::iterator c, std::mutex &mutex) :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we are using single char variables elsewhere but we should move away from this, can we name this variable something more descriptive, please?

Copy link
Collaborator Author

@julianoes julianoes Sep 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 173ac1a.

FAILED
} _state = State::NONE;
std::mutex _state_mutex {};
static constexpr double DEFAULT_TIMEOUT_NORMAL_S = 0.5;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to find a way to get the default timeouts into the documentation (if they aren't already there), this is important behavior that should be visible to external developers

Copy link
Collaborator

@hamishwillee hamishwillee Sep 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julianoes @mrpollo Arguably some timeouts should actually be part of the settable public API - and if so they could then be documented in the same way as everything else (?).

@julianoes Are all timeouts named consistently so we can find them? (i.e. can I have a list)

I've added mavlink/MAVSDK-docs#30 for tracking

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I agree. Let's check this later.


struct Work {
int retries_to_do = 3;
double timeout_s = 0.5;
int num_sent = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a more descriptive name here? is num_set the number of times a command has been set after retries? I tried following the code and got a bit confused

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is num_sent, not num_set but I've changed it to num_command_sent in a746eab.

}
}

void TimeoutHandler::update(double new_duration_s, const void *cookie)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about updated_duration_s instead of new_duration_s?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks. See ea4cdb8.

@mrpollo mrpollo merged commit a9f2199 into fix-android-promises Sep 26, 2017
@mrpollo mrpollo deleted the async-commands branch September 26, 2017 16:57
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

Successfully merging this pull request may close these issues.

4 participants