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

Question about the new definition std :: jthread #73

Open
Jamaika1 opened this issue Oct 12, 2020 · 5 comments
Open

Question about the new definition std :: jthread #73

Jamaika1 opened this issue Oct 12, 2020 · 5 comments

Comments

@Jamaika1
Copy link

How different is the std::thread from std::jthread?
Does it make sense to change definitions for c++20?
Is std::jthread only under c++20?
I was able to compile std::jthread under c++17. Is it compatible with mingw.thread?
https://github.com/josuttis/jthread

@nmcclatchey
Copy link
Contributor

In short, [jthread|https://en.cppreference.com/w/cpp/thread/jthread] is fairly similar to thread due to being built on top of it (the linked jthread repository uses an underlying stop_source and ::std::thread). Because it builds on the standard thread and provides the other requisite classes, it ought to be compatible with mingw.thread. Note, however, that the linked repository uses features not available in C++11 and C++14, which indicates that it would need to be re-implemented if jthread were to be added to this repository.

In short: Mingw.thread should be sufficient for jthread, as linked, but the linked jthread is not suitable (in its current state) for the mingw.thread repository.

@Jamaika1
Copy link
Author

Thanks for info
I compiled the following josuttis/jthread with mingw for c++17 for openexr. I don't know. Does it make sense? Is it legal since if jthread is patented for c++20?
I am interested in this issue for the new JPEG codecs in c ++ 17.
For c++11 and c++14 I needed new features from c++17. There is no point in looking for std::is_same_v and std::is_nothrow_constructible_v replacements here.
For c ++ 20 I also compiled but without jthread.h because the editor already has this library.
AcademySoftwareFoundation/openexr@5960824

Summarizing. Is jthread and thread the same only for other languages?

@Jamaika1 Jamaika1 reopened this Oct 14, 2020
@nmcclatchey
Copy link
Contributor

@Jamaika1 Generally speaking, check the license. In the case of the repository you linked, the license for that particular implementation is listed in the readme: "The code is licensed under a Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/)."

That said, this is no longer relevant to the mingw-std-threads repository. If you are interested in asking questions about licensing, it is likely that you can find answers in another location, such as Stack Overflow.

@Jamaika1
Copy link
Author

Jamaika1 commented Oct 16, 2020

Generally. Then why all this jthread ad?
For gcc, the function < thread > has jthread inside and in c++20 it doesn't need jthread.hpp. Is there something more here than in compilers?
Do you know any jthread libraries for c++11/14/17? Is there a stupid question in itself?

@nmcclatchey
Copy link
Contributor

Generally speaking, the goal would be to have a complete implementation of the C++ standard library. This applies to the libraries shipped with compilers (GCC, Clang, Visual Studio, etc.). It also applies to this repository, because this repository is intended to provide the thread implementation that is missing in MinGW and MinGW-w64.

As of C++20, that list of libraries includes jthread.

That said, the library you linked is the closest that I currently know of to a jthread library for earlier versions of C++. According to its license, it can be forked (copied) and adapted to work with C++11 and C++14, provided that the original author is credited and any changes are noted.

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

No branches or pull requests

2 participants