From b37f1aa6398065be806e6605a023189685669885 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 15 Feb 2017 03:55:15 +0200 Subject: Implement parallel match --- build2/types | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) (limited to 'build2/types') diff --git a/build2/types b/build2/types index 82ee889..de0ae3f 100644 --- a/build2/types +++ b/build2/types @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #if defined(__cpp_lib_shared_mutex) || defined(__cpp_lib_shared_timed_mutex) @@ -82,9 +84,21 @@ namespace build2 // Concurrency. // - using atomic_count = std::atomic; // Matches scheduler::atomic_count. + using std::atomic; + using std::memory_order; + using std::memory_order_relaxed; + using std::memory_order_consume; + using std::memory_order_acquire; + using std::memory_order_release; + using std::memory_order_acq_rel; + using std::memory_order_seq_cst; - using std::future; + using atomic_count = atomic; // Matches scheduler::atomic_count. + + using std::mutex; + using mlock = std::unique_lock; + + using std::condition_variable; #if defined(__cpp_lib_shared_mutex) using shared_mutex = std::shared_mutex; @@ -98,7 +112,15 @@ namespace build2 // Because we have this fallback, we need to be careful not to create // multiple shared locks in the same thread. // - using shared_mutex = std::mutex; + struct shared_mutex: mutex + { + using mutex::mutex; + + void lock_shared () { lock (); } + void try_lock_shared () { try_lock (); } + void unlock_shared () { unlock (); } + }; + using ulock = std::unique_lock; using slock = ulock; #endif @@ -106,6 +128,9 @@ namespace build2 using std::defer_lock; using std::adopt_lock; + using std::future; + namespace this_thread = std::this_thread; + // Exceptions. // // While is included, there is no using for std::exception -- @@ -162,6 +187,7 @@ namespace build2 using butl::timestamp; using butl::duration; using butl::timestamp_unknown; + using butl::timestamp_unknown_rep; using butl::timestamp_nonexistent; using butl::operator<<; @@ -186,7 +212,12 @@ namespace build2 // See context. // - enum class run_phase {load, search_match, execute}; + enum class run_phase {load, match, execute}; + + ostream& + operator<< (ostream&, run_phase); // utility.cxx + + extern run_phase phase; } // In order to be found (via ADL) these have to be either in std:: or in -- cgit v1.1