From 61377c582e0f2675baa5f5e6e30a35d1a4164b33 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 1 May 2017 16:08:43 +0300 Subject: Add hxx extension for headers and lib prefix for library dir --- libbutl/process-details.hxx | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 libbutl/process-details.hxx (limited to 'libbutl/process-details.hxx') diff --git a/libbutl/process-details.hxx b/libbutl/process-details.hxx new file mode 100644 index 0000000..b078cbb --- /dev/null +++ b/libbutl/process-details.hxx @@ -0,0 +1,49 @@ +// file : libbutl/process-details.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef LIBBUTL_PROCESS_DETAILS_HXX +#define LIBBUTL_PROCESS_DETAILS_HXX + +#include + +#include +#if defined(__cpp_lib_shared_mutex) || defined(__cpp_lib_shared_timed_mutex) +# include +#endif + +namespace butl +{ +#if defined(__cpp_lib_shared_mutex) + using shared_mutex = std::shared_mutex; + using ulock = std::unique_lock; + using slock = std::shared_lock; +#elif defined(__cpp_lib_shared_timed_mutex) + using shared_mutex = std::shared_timed_mutex; + using ulock = std::unique_lock; + using slock = std::shared_lock; +#else + // Because we have this fallback, we need to be careful not to create + // multiple shared locks in the same thread. + // + struct shared_mutex: std::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 + + // Mutex that is acquired to make a sequence of operations atomic in regards + // to child process spawning. Must be aquired for exclusive access for child + // process startup, and for shared access otherwise. Defined in process.cxx. + // + extern shared_mutex process_spawn_mutex; +} + +#endif // LIBBUTL_PROCESS_DETAILS_HXX -- cgit v1.1