diff options
Diffstat (limited to 'gdbsupport/thread-pool.h')
-rw-r--r-- | gdbsupport/thread-pool.h | 91 |
1 files changed, 2 insertions, 89 deletions
diff --git a/gdbsupport/thread-pool.h b/gdbsupport/thread-pool.h index f3ac94b..b5b2934 100644 --- a/gdbsupport/thread-pool.h +++ b/gdbsupport/thread-pool.h @@ -24,99 +24,12 @@ #include <vector> #include <functional> #include <chrono> -#if CXX_STD_THREAD -#include <thread> -#include <mutex> -#include <condition_variable> -#include <future> -#endif #include <optional> -namespace gdb -{ - -#if CXX_STD_THREAD - -/* Simply use the standard future. */ -template<typename T> -using future = std::future<T>; - -/* ... and the standard future_status. */ -using future_status = std::future_status; - -#else /* CXX_STD_THREAD */ - -/* A compatibility enum for std::future_status. This is just the - subset needed by gdb. */ -enum class future_status -{ - ready, - timeout, -}; - -/* A compatibility wrapper for std::future. Once <thread> and - <future> are available in all GCC builds -- should that ever happen - -- this can be removed. GCC does not implement threading for - MinGW, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93687. - - Meanwhile, in this mode, there are no threads. Tasks submitted to - the thread pool are invoked immediately and their result is stored - here. The base template here simply wraps a T and provides some - std::future compatibility methods. The provided methods are chosen - based on what GDB needs presently. */ - -template<typename T> -class future -{ -public: - - explicit future (T value) - : m_value (std::move (value)) - { - } - - future () = default; - future (future &&other) = default; - future (const future &other) = delete; - future &operator= (future &&other) = default; - future &operator= (const future &other) = delete; +#include "gdbsupport/cxx-thread.h" - void wait () const { } - - template<class Rep, class Period> - future_status wait_for (const std::chrono::duration<Rep,Period> &duration) - const - { - return future_status::ready; - } - - T get () { return std::move (m_value); } - -private: - - T m_value; -}; - -/* A specialization for void. */ - -template<> -class future<void> +namespace gdb { -public: - void wait () const { } - - template<class Rep, class Period> - future_status wait_for (const std::chrono::duration<Rep,Period> &duration) - const - { - return future_status::ready; - } - - void get () { } -}; - -#endif /* CXX_STD_THREAD */ - /* A thread pool. |