MinGW workaround with USE_github_com_meganz_mingw_std_threads

This commit is contained in:
qPCR4vir 2015-12-02 13:38:22 +01:00
parent 003b0b4041
commit 74be76e49a
5 changed files with 42 additions and 10 deletions

View File

@ -3,10 +3,14 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#if defined(USE_github_com_meganz_mingw_std_threads)
#include <mingw.condition_variable.h>
#else
#include <boost/thread/condition_variable.hpp> #include <boost/thread/condition_variable.hpp>
namespace std namespace std
{ {
typedef boost::condition_variable condition_variable; typedef boost::condition_variable condition_variable;
} }
#endif #endif // (USE_github_com_meganz_mingw_std_threads)
#endif // (STD_THREAD_NOT_SUPPORTED)
#endif // NANA_STD_CONDITION_VARIABLE_HPP #endif // NANA_STD_CONDITION_VARIABLE_HPP

View File

@ -3,6 +3,20 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#if defined(USE_github_com_meganz_mingw_std_threads)
#include <windows.h>
#include <mutex>
#include <condition_variable>
#include <thread>
#include <pthread.h>
#include <errno.h>
#include <cstdio>
// http://lxr.free-electrons.com/source/include/uapi/asm-generic/errno.h#L53
#define EPROTO 71 /* Protocol error */
#include <mingw.thread.h>
#include <mingw.mutex.h>
#else
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp> #include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/locks.hpp> #include <boost/thread/locks.hpp>
@ -18,5 +32,6 @@ namespace std
typedef boost::mutex mutex; typedef boost::mutex mutex;
typedef boost::recursive_mutex recursive_mutex; typedef boost::recursive_mutex recursive_mutex;
} }
#endif #endif // (USE_github_com_meganz_mingw_std_threads)
#endif // (STD_THREAD_NOT_SUPPORTED)
#endif // NANA_STD_MUTEX_HPP #endif // NANA_STD_MUTEX_HPP

View File

@ -3,11 +3,15 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#if defined(USE_github_com_meganz_mingw_std_threads)
#include <mingw.thread.h>
#else
#include <boost/thread.hpp> #include <boost/thread.hpp>
namespace std namespace std
{ {
typedef boost::thread thread; typedef boost::thread thread;
} }
#endif #endif // (USE_github_com_meganz_mingw_std_threads)
#endif // (STD_THREAD_NOT_SUPPORTED)
#endif // NANA_STD_THREAD_HPP #endif // NANA_STD_THREAD_HPP

View File

@ -14,9 +14,16 @@
#include <nana/gui/widgets/widget.hpp> #include <nana/gui/widgets/widget.hpp>
#include <unordered_map> #include <unordered_map>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream> // Warning:(17, 1) [unused] Unused import statement
#include <memory> #include <memory> // Warning:(17, 1) [unused] Unused import statement
#if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp>
#else
#include <mutex> #include <mutex>
#endif
#include <map> #include <map>
namespace nana namespace nana
@ -68,7 +75,7 @@ namespace nana
bool escape = false; bool escape = false;
for (auto i = read_ptr_ + 1; i != end_ptr_; ++i) for (auto i = read_ptr_ + 1; i != end_ptr_; ++i)
{ {
if (escape) if (escape) // Warning:(78, 12) Condition is always false
{ {
escape = false; escape = false;
continue; continue;
@ -261,8 +268,9 @@ namespace nana
{ {
auto result = mgr.table.emplace(wd, std::move(eval)); auto result = mgr.table.emplace(wd, std::move(eval));
result.first->second.destroy = nana::API::events(wd).destroy([wd]{ result.first->second.destroy = nana::API::events(wd).destroy([wd]{
auto & mgr = get_eval_manager(); auto & mgr = get_eval_manager(); // Warning:(271, 13) Local 'mgr' hides previous declaration
std::lock_guard<std::recursive_mutex> lock(mgr.mutex); std::lock_guard<std::recursive_mutex> lock(mgr.mutex); // Local 'lock' hides previous
mgr.table.erase(wd); mgr.table.erase(wd);
}); });
} }

View File

@ -17,8 +17,9 @@
#include <vector> #include <vector>
#if defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_condition_variable.hpp>
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#include <nana/std_condition_variable.hpp>
#else #else
#include <condition_variable> #include <condition_variable>
#include <mutex> #include <mutex>