-
Notifications
You must be signed in to change notification settings - Fork 253
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
Small issue with lates release #44
Comments
Thanks for opening the issue @Green-Sky. I'm glad you like the simplicity of the library, this is indeed one of its core design principles :) Regarding vectors: yes, you cannot copy an That being said, I do feel that using a smart pointer here would be better (even though whenever I use smart pointers people always tell me "why didn't you just use a vector??") and I will change that in a future release. Meanwhile you can replace std::vector<std::atomic<bool>> flags(n) with std::unique_ptr<std::atomic<bool>[]> flags = std::make_unique<std::atomic<bool>[]>(n) (and similarly for the other vectors) to avoid this issue. Regarding cppcheck: I've never used it before but I tried it now and the only thing it told me is to "Consider using I don't think it's true that Regarding task priority: I've actually been thinking of adding that functionality, but it seems to me that |
Yes I did get that one too and intentionally ignored it 😄 .
A quick look turned up this, but its quiet dated (~2006 from the looks of it)
Just take a look at the changes I made, they are not many. |
I tried that but still don't get that message. Here's the full output:
(I also added Maybe we're not using the same version? I'm using 2.8.
Thanks, I will take a look at some point in the future, but right now I have higher-priority things to work on (pun intended ;) |
Oh gad, looks like mine is ancient: 1.90 (ubuntu 20.04) my full output:
Yea sure, also lol. |
Interesting. I think they probably made it smarter in subsequent versions, and therefore the new version recognizes that this is not really an issue. Thanks! :) |
So I was extending the fresh thread-pool release with a priority_queue. While doing so I ran into multiple issues:
std::vector<std::atomic<bool>>
seems to be invalid code.I read that
std::atomic
is non-copyable and non-movable, whilestd::vector
requires at least either.flag1 == falg2
comparing the same value.Not sure if cppcheck is right here, but I think a compiler might optimize this away...
Possible solution: declaring
bool flag;
avolatile
.I really like how simple the Library is 😃
My wip code: https://github.com/Green-Sky/thread-pool/commits/priority_queue
Right now my code consistently fails the "task monitoring" test. I suspect the first issue to be the cause.
The text was updated successfully, but these errors were encountered: