-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Prevent deadlock with BULK transfert and reduce log noise #13735
Conversation
In #13622 we have a open discussion because of the interface number for bulk already |
Ah yeah, completely forgot about that one. I guess we might still want to get that PR for timeout and error detection fix? |
I think this one is not in conflict with #13622 |
dd7a5b9
to
6aa11ac
Compare
Realised that the signature change makes more sense to move into #13737 as it used in there to stop upon comm failure. Repurposing the PR for only timeout and spamming log messages |
1c2e7bc
to
74de707
Compare
@Swiftb0y the code suggestion doesn't seem to work. Any suggestion to fix it? |
#include "util/time.h" | ||
#include "util/trace.h" | ||
|
||
namespace { | ||
using namespace std::literals; | ||
constexpr std::seconds kBulkSendTimeout = 5s; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is:
using namespace std::literals::chrono_literals;
constexpr std::chrono::seconds kBulkSendTimeout = 5s;
However the struggle here, confirms IMHO that using 5s is a bit over engineered here when not using this for chronio functions. So I would release the compiler from some work and use use the libusb type without a cast:
constexpr unsigned int kBulkSendTimeoutMs = 5000;
The Ms prefix documents the value unit.
Both is fine for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree honestly. The added compile time is negligible. This is about avoiding primitive obsession.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The resource you linked make sense, but in our case, we don't own the API and simply must comply to libusb asking for a tasteless uint
.
To be honest, I'm leaning towards @daschuer's suggestion as I find it more readable - std::milliseconds(kBulkSendTimeout).count()
feels a bit cryptic to me (had to go to the std lib to see what count
was doing). Appreciate you are trying to roll out std on time within the Mixxx API tho so can't make up my mind.
Would a @mixxxdj/developers help us with the tie here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I'm in favor for these literal types, and we should all get common to this std C++ syntax, as libraries like Qt convert their timing types towards this standard.
In this case, the literal type give us no type safety, as it's converted to the raw integer type before use.
Regarding readability, where a const value is only used once in the whole code - inline with the unit as comment is IMHO the most readable style:
c_function(5000, // Send timeout in milliseconds
otherArgument);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @JoergAtGithub , that does sound like a great middle ground. @daschuer @Swiftb0y happy with that option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, the literal type give us no type safety, as it's converted to the raw integer type before use.
Yeah thats unfortunate, but the conversion is done at the API boundary (so its like calling .get()
on a unique_ptr when passing to a C API). Its also easier (in theory/general) to upgrade to the newer API if the conversion is done here, but since this is a C API, that will never happen. I still prefer my original solution (an unnamed constant is not much better), but I won't insist on it. Just my two cents for what is best in the general case. This is only a one-off so as you rightfully pointed out, it doesn't make much difference. I'm fine with anything in this particular case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I already mentioned, all suggestions are fine for me as well.
I can confirm the original request of @Swiftb0y to replace a comment by code.
Comment difficult code, but avoid comments by making the code itself expressive when possible.
fbd5fe5
to
1d1a5e9
Compare
whoops, yeah. Its #include <chrono>
using namespace std::literals;
constexpr std::chrono::seconds kBulkSendTimeout = 5s;
int usage() {
return std::chrono::milliseconds(kBulkSendTimeout).count();
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not blocking this any further. please fix pre-commit and clang-tidy and then its LGTM.
683fac2
to
0053ca0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.LGTM
--controller-debug