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

Convert __sync* built-ins to std::atomic #265

Closed
wants to merge 3 commits into from

Conversation

kannibalox
Copy link
Contributor

I suspect these changes mean that lt_cacheline_aligned is no longer required for some of the objects, but left them alone since I wasn't 100% on that.

Addresses #253

Notable changes:

  • The thread_base::*_main_polling() functions didn't appear to be used outside of a test, so I removed them entirely
  • thread_base's pthread_mutex_t was changed to std::mutex
  • instrumentation.cc was changed to log lines indicating when libtorrent wasn't compiled with it enabled
  • If thread_base::m_global was simply changed to use std::atomic/std::mutex, it couldn't be initialized as a protected static member outside of the class in C++14 due to not being able to guarantee copy elision for std::atomic's construction. C++17 fixes this, but in the meantime I broke it out into two separate members since we shouldn't strictly need to lt_cacheline_aligned them together anymore.

Also convert thread_base to use std::mutex instead of pthread_mutex
Also remove unused TaskManager test files
@@ -37,6 +37,8 @@
#ifndef LIBTORRENT_UTILS_THREAD_INTERRUPT_H
#define LIBTORRENT_UTILS_THREAD_INTERRUPT_H

#include "config.h"
Copy link
Owner

Choose a reason for hiding this comment

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

This should never be in a header file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no quarrel with that, but it throws off clang-tidy since it can't infer what lt_cacheline_aligned is.

@rakshasa
Copy link
Owner

rakshasa commented Dec 1, 2024

Check fix/atomic-types before making any changes, as I've done some more extensive work on fixing things there. #266

@kannibalox
Copy link
Contributor Author

I have no problem with this getting closed in favor of your work, otherwise I'll wait until it's merged into master and compare/contrast at that point.

@rakshasa
Copy link
Owner

rakshasa commented Dec 2, 2024

I'd rather do the conversion myself as they need careful consideration and there are some improvements I'd like to do.

@rakshasa rakshasa closed this Dec 4, 2024
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.

2 participants