meganz / mingw-std-threads

Standard threads implementation currently still missing on MinGW GCC on Windows
BSD 2-Clause "Simplified" License
439 stars 137 forks source link

Core features from <future> #43

Closed nmcclatchey closed 6 years ago

nmcclatchey commented 6 years ago

Implements core features of the C++11 <future> header. Specifically, this pull request adds support for

Some work yet remains before the library can be considered final. Specifically,

Though unrelated, the pull request also changes certain protected members of thread to be private and replaces a standard-violating macro. Names with an underscore followed by a capital letter are reserved by the standard; the macro's purpose can be accomplished safely by using a static constexpr variable at class scope instead.

Jamaika1 commented 6 years ago

Hi team I used your mingw-std-threads-6bd14b1ba5946b18de2f2239fca2b108152cd503.zip attachment. I know that there are still tests. Unfortunately, I have a problem with libheif.

mingw.future.h: In instantiation of 'static void _mingw_stdthread::detail::StorageHelper::store_deferred(mingw_stdthread::detail::FutureState, Func&&, Args&& ...) [with Func = heif::Error (heif::HeifContext::&)(unsigned int, std::shared_ptr, int, int) const; Args = {const heif::HeifContext*&, unsigned int&, std::sharedptr&, int&, int&}; Ret = heif::Error]':

_mingw.future.h:947:19: required from 'static void mingw_stdthread::detail::StorageHelper::store(mingw_stdthread::detail::FutureState, Func&&, Args&& ...) [with Func = heif::Error (heif::HeifContext::&)(unsigned int, std::shared_ptr, int, int) const; Args = {const heif::HeifContext*&, unsigned int&, std::sharedptr&, int&, int&}; Ret = heif::Error]'

_mingw.future.h:1066:24: required from 'std::future<typename std::__invoke_result<typename std::decay<_Tp>::type, typename std::decay<_Args>::type ...>::type> std::async(std::launch, _Fn&&, _Args&& ...) [with _Fn = heif::Error (heif::HeifContext::)(unsigned int, std::shared_ptr, int, int) const; _Args = {const heif::HeifContext, unsigned int&, std::shared_ptr&, int&, int&}; typename std::__invoke_result<typename std::decay<_Tp>::type, typename std::decay<_Args>::type ...>::type = heif::Error]'_

_heifcontext.cc:1185:77: required from here

_mingw.future.h:938:52: error: must use '.' or '->' to call pointer-to-member function in 'std::forward<heif::Error (heif::HeifContext::&)(unsigned int, std::shared_ptr, int, int) const>(( & func)) (...)', e.g. '(... -> std::forward<heif::Error (heif::HeifContext::&)(unsigned int, std::sharedptr, int, int) const>((* & func))) (...)'

938 | state_ptr->set_value(std::forward(func)(std::forward(args)...));

nmcclatchey commented 6 years ago

Good catch. I'll replace the function call with invoke.

nmcclatchey commented 6 years ago

That particular problem should be fixed. If you find any others, please let me know ASAP.

Jamaika1 commented 6 years ago

Thanks