diff options
author | 2013-05-16 20:03:48 +0100 | |
---|---|---|
committer | 2013-05-22 23:19:18 +0100 | |
commit | 78d9a9bf0758140e0e8c03c5e8d3288f74efbb51 (patch) | |
tree | 1c0b25ba6358e80d0fe535fb49e3cce8d243e6a3 | |
parent | 39834ca3b05fadb14f855a8ab6dcea98c35738a7 (diff) | |
download | paludis-78d9a9bf0758140e0e8c03c5e8d3288f74efbb51.tar.gz paludis-78d9a9bf0758140e0e8c03c5e8d3288f74efbb51.tar.xz |
Switch to std mutex and condition_variable
86 files changed, 563 insertions, 1118 deletions
diff --git a/paludis/broken_linkage_finder.cc b/paludis/broken_linkage_finder.cc index 2cc0cbaa9..0ad1d3d8a 100644 --- a/paludis/broken_linkage_finder.cc +++ b/paludis/broken_linkage_finder.cc @@ -25,7 +25,6 @@ #include <paludis/util/realpath.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/set-impl.hh> #include <paludis/util/sequence-impl.hh> @@ -54,6 +53,7 @@ #include <map> #include <set> #include <vector> +#include <mutex> using namespace paludis; @@ -73,7 +73,7 @@ namespace paludis std::vector<std::shared_ptr<LinkageChecker> > checkers; std::set<FSPath, FSPathComparator> extra_lib_dirs; - Mutex mutex; + std::mutex mutex; bool has_files; Files files; @@ -237,7 +237,7 @@ Imp<BrokenLinkageFinder>::walk_directory(const FSPath & directory) Log::get_instance()->message("broken_linkage_finder.entering", ll_debug, lc_context) << "Entering directory '" << directory << "'"; { - Lock l(mutex); + std::unique_lock<std::mutex> l(mutex); extra_lib_dirs.erase(without_root); } @@ -341,7 +341,7 @@ Imp<BrokenLinkageFinder>::gather_package(const std::shared_ptr<const PackageID> const ContentsFileEntry * file(visitor_cast<const ContentsFileEntry>(**it)); if (0 != file) { - Lock l(mutex); + std::unique_lock<std::mutex> l(mutex); files.insert(std::make_pair(file->location_key()->parse_value(), pkg)); } } diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc index 29a31422b..df4f1ba27 100644 --- a/paludis/dep_spec.cc +++ b/paludis/dep_spec.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -27,7 +27,6 @@ #include <paludis/util/join.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/sequence-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/wrapped_output_iterator.hh> diff --git a/paludis/distribution-impl.hh b/paludis/distribution-impl.hh index 6715d1d27..7eb835068 100644 --- a/paludis/distribution-impl.hh +++ b/paludis/distribution-impl.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -21,19 +21,19 @@ #define PALUDIS_GUARD_PALUDIS_DISTRIBUTION_IMPL_HH 1 #include <paludis/distribution.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/config_file.hh> #include <paludis/util/options.hh> #include <paludis/util/pimp-impl.hh> #include <unordered_map> +#include <mutex> namespace paludis { template <typename Data_> struct Imp<ExtraDistributionData<Data_> > { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::unordered_map<std::string, std::shared_ptr<const Data_>, Hash<std::string> > values; }; @@ -55,7 +55,7 @@ namespace paludis const std::shared_ptr<const Data_> ExtraDistributionData<Data_>::data_from_distribution(const Distribution & d) const { - Lock lock(this->_imp->mutex); + std::unique_lock<std::mutex> lock(this->_imp->mutex); typename std::unordered_map<std::string, std::shared_ptr<const Data_>, Hash<std::string> >::const_iterator v( this->_imp->values.find(d.name())); if (this->_imp->values.end() != v) diff --git a/paludis/elf_linkage_checker.cc b/paludis/elf_linkage_checker.cc index 93c4fcda6..713c8f619 100644 --- a/paludis/elf_linkage_checker.cc +++ b/paludis/elf_linkage_checker.cc @@ -28,7 +28,6 @@ #include <paludis/util/realpath.hh> #include <paludis/util/join.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> @@ -45,6 +44,7 @@ #include <map> #include <set> #include <vector> +#include <mutex> using namespace paludis; @@ -109,7 +109,7 @@ namespace paludis FSPath root; std::set<std::string> check_libraries; - Mutex mutex; + std::mutex mutex; std::map<FSPath, ElfArchitecture, FSPathComparator> seen; Symlinks symlinks; @@ -176,7 +176,7 @@ Imp<ElfLinkageChecker>::check_elf(const FSPath & file, std::istream & stream) ElfArchitecture arch(elf); elf.resolve_all_strings(); - Lock l(mutex); + std::unique_lock<std::mutex> l(mutex); if (check_libraries.empty() && ET_DYN == elf.get_type()) handle_library(file, arch); @@ -242,7 +242,7 @@ ElfLinkageChecker::note_symlink(const FSPath & link, const FSPath & target) { if (_imp->check_libraries.empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> l(_imp->mutex); std::map<FSPath, ElfArchitecture, FSPathComparator>::const_iterator it(_imp->seen.find(target)); if (_imp->seen.end() != it) diff --git a/paludis/environment_implementation.cc b/paludis/environment_implementation.cc index ad6a2f7ef..8ddcbf5ac 100644 --- a/paludis/environment_implementation.cc +++ b/paludis/environment_implementation.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -35,7 +35,6 @@ #include <paludis/util/set.hh> #include <paludis/util/system.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/member_iterator-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/wrapped_output_iterator.hh> @@ -48,6 +47,7 @@ #include <paludis/util/set-impl.hh> #include <algorithm> +#include <mutex> #include <map> #include <list> #include <set> @@ -132,7 +132,7 @@ namespace paludis std::list<std::shared_ptr<Repository> > repositories; std::multimap<int, std::list<std::shared_ptr<Repository> >::iterator> repository_importances; - mutable Mutex sets_mutex; + mutable std::recursive_mutex sets_mutex; mutable bool loaded_sets; mutable std::shared_ptr<SetNameSet> set_names; mutable SetsStore sets; @@ -236,7 +236,7 @@ EnvironmentImplementation::add_set( const std::function<std::shared_ptr<const SetSpecTree> ()> & func, const bool combine) const { - Lock lock(_imp->sets_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->sets_mutex); Context context("When adding set named '" + stringify(name) + ":"); if (combine) @@ -263,7 +263,7 @@ EnvironmentImplementation::add_set( std::shared_ptr<const SetNameSet> EnvironmentImplementation::set_names() const { - Lock lock(_imp->sets_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->sets_mutex); _need_sets(); return _imp->set_names; @@ -272,7 +272,7 @@ EnvironmentImplementation::set_names() const const std::shared_ptr<const SetSpecTree> EnvironmentImplementation::set(const SetName & s) const { - Lock lock(_imp->sets_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->sets_mutex); _need_sets(); SetsStore::const_iterator i(_imp->sets.find(s)); diff --git a/paludis/environments/paludis/keywords_conf.cc b/paludis/environments/paludis/keywords_conf.cc index 4837cfb12..bf99ed348 100644 --- a/paludis/environments/paludis/keywords_conf.cc +++ b/paludis/environments/paludis/keywords_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -34,14 +34,14 @@ #include <paludis/util/tokeniser.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/wrapped_forward_iterator.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/set.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_null_shared_ptr.hh> -#include <unordered_map> #include <list> -#include <vector> #include <map> +#include <mutex> +#include <unordered_map> +#include <vector> using namespace paludis; using namespace paludis::paludis_environment; @@ -64,7 +64,7 @@ namespace paludis SpecificMap qualified; UnspecificMap unqualified; mutable NamedSetMap set; - mutable Mutex set_mutex; + mutable std::mutex set_mutex; Imp(const PaludisEnvironment * const e) : env(e) @@ -173,7 +173,7 @@ KeywordsConf::query(const std::shared_ptr<const KeywordNameSet> & k, const std:: /* next: named sets */ { - Lock lock(_imp->set_mutex); + std::unique_lock<std::mutex> lock(_imp->set_mutex); for (NamedSetMap::iterator i(_imp->set.begin()), i_end(_imp->set.end()) ; i != i_end ; ++i) diff --git a/paludis/environments/paludis/licenses_conf.cc b/paludis/environments/paludis/licenses_conf.cc index a9e9b5421..be975ff83 100644 --- a/paludis/environments/paludis/licenses_conf.cc +++ b/paludis/environments/paludis/licenses_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -32,16 +32,16 @@ #include <paludis/util/log.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/set.hh> -#include <unordered_map> #include <list> -#include <vector> #include <map> +#include <mutex> +#include <unordered_map> +#include <vector> using namespace paludis; using namespace paludis::paludis_environment; @@ -64,8 +64,8 @@ namespace paludis mutable SpecificMap qualified; mutable UnspecificMap unqualified; mutable NamedSetMap set; - mutable Mutex set_mutex; - mutable Mutex expanded_mutex; + mutable std::mutex set_mutex; + mutable std::mutex expanded_mutex; mutable bool expanded; Imp(const PaludisEnvironment * const e) : @@ -168,7 +168,7 @@ bool LicensesConf::query(const std::string & t, const std::shared_ptr<const PackageID> & e) const { { - Lock lock(_imp->expanded_mutex); + std::unique_lock<std::mutex> lock(_imp->expanded_mutex); if (! _imp->expanded) { _imp->expanded = true; @@ -224,7 +224,7 @@ LicensesConf::query(const std::string & t, const std::shared_ptr<const PackageID /* next: named sets */ { - Lock lock(_imp->set_mutex); + std::unique_lock<std::mutex> lock(_imp->set_mutex); for (NamedSetMap::iterator i(_imp->set.begin()), i_end(_imp->set.end()) ; i != i_end ; ++i) { diff --git a/paludis/environments/paludis/package_mask_conf.cc b/paludis/environments/paludis/package_mask_conf.cc index 532453aab..ae82223d5 100644 --- a/paludis/environments/paludis/package_mask_conf.cc +++ b/paludis/environments/paludis/package_mask_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -34,14 +34,14 @@ #include <paludis/util/tokeniser.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/indirect_iterator-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/make_null_shared_ptr.hh> -#include <vector> -#include <list> -#include <set> #include <algorithm> #include <functional> +#include <list> +#include <mutex> +#include <set> +#include <vector> using namespace paludis; using namespace paludis::paludis_environment; @@ -57,7 +57,7 @@ namespace paludis const bool allow_reasons; std::list<std::pair<std::shared_ptr<const PackageDepSpec>, std::set<std::string> > > masks; mutable Sets sets; - mutable Mutex set_mutex; + mutable std::mutex set_mutex; Imp(const PaludisEnvironment * const e, const bool a) : env(e), @@ -136,7 +136,7 @@ PackageMaskConf::query(const std::shared_ptr<const PackageID> & e, const std::st } { - Lock lock(_imp->set_mutex); + std::unique_lock<std::mutex> lock(_imp->set_mutex); for (Sets::iterator it(_imp->sets.begin()), it_end(_imp->sets.end()); it_end != it; ++it) diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc index f70154b7f..5f7b777bd 100644 --- a/paludis/environments/paludis/paludis_config.cc +++ b/paludis/environments/paludis/paludis_config.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -40,7 +40,6 @@ #include <paludis/util/system.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/wrapped_output_iterator.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/make_named_values.hh> @@ -65,6 +64,7 @@ #include <list> #include <map> #include <vector> +#include <mutex> #include <ctype.h> #include <sys/types.h> @@ -73,12 +73,6 @@ #include "config.h" -/** \file - * Imp of paludis_config.hh classes. - * - * \ingroup grppaludisconfig - */ - using namespace paludis; using namespace paludis::paludis_environment; @@ -175,7 +169,7 @@ namespace paludis std::string root; std::string system_root; std::string config_dir; - mutable Mutex distribution_mutex; + mutable std::mutex distribution_mutex; mutable std::string distribution; std::shared_ptr<FSPathSequence> bashrc_files; @@ -194,11 +188,11 @@ namespace paludis std::shared_ptr<SuggestionsConf> suggestions_conf; mutable std::shared_ptr<World> world; - mutable Mutex reduced_mutex; + mutable std::mutex reduced_mutex; mutable std::shared_ptr<uid_t> reduced_uid; mutable std::shared_ptr<gid_t> reduced_gid; - mutable Mutex general_conf_mutex; + mutable std::mutex general_conf_mutex; mutable bool has_general_conf; mutable bool accept_all_breaks_portage; mutable Set<std::string> accept_breaks_portage; @@ -234,7 +228,7 @@ namespace paludis void Imp<PaludisConfig>::need_general_conf() const { - Lock lock(general_conf_mutex); + std::unique_lock<std::mutex> lock(general_conf_mutex); if (has_general_conf) return; @@ -1002,7 +996,7 @@ PaludisConfig::config_dir() const uid_t PaludisConfig::reduced_uid() const { - Lock lock(_imp->reduced_mutex); + std::unique_lock<std::mutex> lock(_imp->reduced_mutex); if (! _imp->reduced_uid) { @@ -1033,7 +1027,7 @@ PaludisConfig::reduced_uid() const gid_t PaludisConfig::reduced_gid() const { - Lock lock(_imp->reduced_mutex); + std::unique_lock<std::mutex> lock(_imp->reduced_mutex); if (! _imp->reduced_gid) { @@ -1142,7 +1136,7 @@ PaludisConfig::world() const std::string PaludisConfig::distribution() const { - Lock lock(_imp->distribution_mutex); + std::unique_lock<std::mutex> lock(_imp->distribution_mutex); if (! _imp->distribution.empty()) return _imp->distribution; diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc index cbe070816..c92972f15 100644 --- a/paludis/environments/paludis/paludis_environment.cc +++ b/paludis/environments/paludis/paludis_environment.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -49,7 +49,6 @@ #include <paludis/util/strip.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/map.hh> #include <paludis/util/wrapped_output_iterator.hh> #include <paludis/util/options.hh> @@ -65,6 +64,7 @@ #include <algorithm> #include <list> #include <map> +#include <mutex> #include <unistd.h> using namespace paludis; @@ -75,14 +75,14 @@ namespace paludis template<> struct Imp<PaludisEnvironment> { - mutable Mutex hook_mutex; + mutable std::mutex hook_mutex; mutable bool done_hooks; mutable std::shared_ptr<Hooker> hooker; mutable std::list<std::pair<FSPath, bool> > hook_dirs; std::shared_ptr<PaludisConfig> config; - mutable Mutex sets_mutex; + mutable std::mutex sets_mutex; mutable std::map<SetName, std::shared_ptr<const SetSpecTree> > sets; std::shared_ptr<LiteralMetadataValueKey<std::string> > format_key; @@ -206,7 +206,7 @@ PaludisEnvironment::perform_hook( const Hook & hook, const std::shared_ptr<OutputManager> & optional_output_manager) const { - Lock lock(_imp->hook_mutex); + std::unique_lock<std::mutex> lock(_imp->hook_mutex); if (! _imp->hooker) { @@ -223,7 +223,7 @@ PaludisEnvironment::perform_hook( std::shared_ptr<const FSPathSequence> PaludisEnvironment::hook_dirs() const { - Lock lock(_imp->hook_mutex); + std::unique_lock<std::mutex> lock(_imp->hook_mutex); _imp->need_hook_dirs(FSPath(_imp->config->config_dir())); @@ -514,7 +514,7 @@ namespace void PaludisEnvironment::populate_sets() const { - Lock lock(_imp->sets_mutex); + std::unique_lock<std::mutex> lock(_imp->sets_mutex); add_set(SetName("world"), SetName("world::environment"), std::bind(&make_world_set, _imp->config->world()), true); std::list<FSPath> sets_dirs; diff --git a/paludis/environments/paludis/suggestions_conf.cc b/paludis/environments/paludis/suggestions_conf.cc index 65c026d91..66304ffc8 100644 --- a/paludis/environments/paludis/suggestions_conf.cc +++ b/paludis/environments/paludis/suggestions_conf.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2010, 2011 Ciaran McCreesh + * Copyright (c) 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -26,7 +26,6 @@ #include <paludis/util/log.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/hashes.hh> @@ -39,10 +38,11 @@ #include <paludis/match_package.hh> #include <paludis/package_id.hh> #include <paludis/dep_spec_annotations.hh> -#include <unordered_map> #include <list> -#include <vector> #include <map> +#include <mutex> +#include <unordered_map> +#include <vector> using namespace paludis; using namespace paludis::paludis_environment; @@ -105,7 +105,7 @@ namespace paludis SpecificMap qualified; UnspecificMap unqualified; mutable NamedSetMap set; - mutable Mutex set_mutex; + mutable std::mutex set_mutex; Imp(const PaludisEnvironment * const e) : env(e) @@ -223,7 +223,7 @@ SuggestionsConf::interest_in_suggestion( /* next: named sets */ { - Lock lock(_imp->set_mutex); + std::unique_lock<std::mutex> lock(_imp->set_mutex); for (NamedSetMap::iterator i(_imp->set.begin()), i_end(_imp->set.end()) ; i != i_end ; ++i) { diff --git a/paludis/environments/paludis/world.cc b/paludis/environments/paludis/world.cc index b546d4f5d..5d5af6ca0 100644 --- a/paludis/environments/paludis/world.cc +++ b/paludis/environments/paludis/world.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -19,7 +19,6 @@ #include <paludis/environments/paludis/world.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/util/log.hh> #include <paludis/util/make_named_values.hh> @@ -29,6 +28,7 @@ #include <paludis/user_dep_spec.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <functional> +#include <mutex> using namespace paludis; using namespace paludis::paludis_environment; @@ -40,7 +40,7 @@ namespace paludis { const Environment * const env; const std::shared_ptr<const FSPath> maybe_world_file; - mutable Mutex mutex; + mutable std::mutex mutex; Imp(const Environment * const e, const std::shared_ptr<const FSPath> & m) : env(e), @@ -97,7 +97,7 @@ World::_add_string_to_world(const std::string & n) const return false; } - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); Context context("When adding '" + n + "' to world file '" + stringify(*_imp->maybe_world_file) + "':"); @@ -141,7 +141,7 @@ World::_remove_string_from_world(const std::string & n) const return result; } - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); Context context("When removing '" + n + "' from world file '" + stringify(*_imp->maybe_world_file) + "':"); diff --git a/paludis/environments/portage/portage_environment.cc b/paludis/environments/portage/portage_environment.cc index 687d4a722..e02721568 100644 --- a/paludis/environments/portage/portage_environment.cc +++ b/paludis/environments/portage/portage_environment.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -53,7 +53,6 @@ #include <paludis/package_id.hh> #include <paludis/user_dep_spec.hh> #include <paludis/set_file.hh> -#include <paludis/util/mutex.hh> #include <paludis/literal_metadata_key.hh> #include <paludis/repository_factory.hh> #include <paludis/choice.hh> @@ -65,6 +64,7 @@ #include <map> #include <vector> #include <list> +#include <mutex> #include <unistd.h> #include <sys/types.h> @@ -108,12 +108,12 @@ namespace paludis std::set<std::string> ignore_breaks_portage; bool ignore_all_breaks_portage; - mutable Mutex reduced_mutex; + mutable std::mutex reduced_mutex; bool userpriv_enabled; mutable std::shared_ptr<uid_t> reduced_uid; mutable std::shared_ptr<gid_t> reduced_gid; - mutable Mutex hook_mutex; + mutable std::mutex hook_mutex; mutable bool done_hooks; mutable std::shared_ptr<Hooker> hooker; mutable std::list<FSPath> hook_dirs; @@ -121,7 +121,7 @@ namespace paludis int overlay_importance; const FSPath world_file; - mutable Mutex world_mutex; + mutable std::mutex world_mutex; std::shared_ptr<LiteralMetadataValueKey<std::string> > format_key; std::shared_ptr<LiteralMetadataValueKey<FSPath> > config_location_key; @@ -704,7 +704,7 @@ PortageEnvironment::perform_hook( { using namespace std::placeholders; - Lock l(_imp->hook_mutex); + std::unique_lock<std::mutex> l(_imp->hook_mutex); if (! _imp->hooker) { _imp->need_hook_dirs(); @@ -719,7 +719,7 @@ PortageEnvironment::perform_hook( std::shared_ptr<const FSPathSequence> PortageEnvironment::hook_dirs() const { - Lock l(_imp->hook_mutex); + std::unique_lock<std::mutex> l(_imp->hook_mutex); _imp->need_hook_dirs(); std::shared_ptr<FSPathSequence> result(std::make_shared<FSPathSequence>()); std::copy(_imp->hook_dirs.begin(), _imp->hook_dirs.end(), result->back_inserter()); @@ -860,7 +860,7 @@ PortageEnvironment::reduced_gid() const gid_t g(getgid()); if (0 == g && _imp->userpriv_enabled) { - Lock lock(_imp->reduced_mutex); + std::unique_lock<std::mutex> lock(_imp->reduced_mutex); if (! _imp->reduced_gid) { @@ -887,7 +887,7 @@ PortageEnvironment::reduced_uid() const uid_t u(getuid()); if (0 == u && _imp->userpriv_enabled) { - Lock lock(_imp->reduced_mutex); + std::unique_lock<std::mutex> lock(_imp->reduced_mutex); if (! _imp->reduced_uid) { @@ -940,7 +940,7 @@ PortageEnvironment::remove_from_world(const SetName & s) const bool PortageEnvironment::_add_string_to_world(const std::string & s) const { - Lock l(_imp->world_mutex); + std::unique_lock<std::mutex> l(_imp->world_mutex); Context context("When adding '" + s + "' to world file '" + stringify(_imp->world_file) + "':"); @@ -976,7 +976,7 @@ PortageEnvironment::_add_string_to_world(const std::string & s) const bool PortageEnvironment::_remove_string_from_world(const std::string & s) const { - Lock l(_imp->world_mutex); + std::unique_lock<std::mutex> l(_imp->world_mutex); Context context("When removing '" + s + "' from world file '" + stringify(_imp->world_file) + "':"); bool result(false); @@ -1073,7 +1073,7 @@ namespace void PortageEnvironment::populate_sets() const { - Lock l(_imp->world_mutex); + std::unique_lock<std::mutex> l(_imp->world_mutex); add_set(SetName("world::environment"), SetName("world"), std::bind(&make_world_set, this, _imp->world_file), true); } diff --git a/paludis/hooker.cc b/paludis/hooker.cc index a2854461b..9f1ec3851 100644 --- a/paludis/hooker.cc +++ b/paludis/hooker.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * Copyright (c) 2007 Piotr Jaroszyński * * This file is part of the Paludis package manager. Paludis is free software; @@ -33,7 +33,6 @@ #include <paludis/util/strip.hh> #include <paludis/util/graph-impl.hh> #include <paludis/util/tokeniser.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/sequence-impl.hh> #include <paludis/util/join.hh> #include <paludis/util/make_named_values.hh> @@ -45,6 +44,7 @@ #include <list> #include <iterator> +#include <mutex> #include <dlfcn.h> #include <stdint.h> @@ -469,7 +469,7 @@ namespace paludis const Environment * const env; std::list<std::pair<FSPath, bool> > dirs; - mutable Mutex hook_files_mutex; + mutable std::recursive_mutex hook_files_mutex; mutable std::map<std::string, std::shared_ptr<Sequence<std::shared_ptr<HookFile> > > > hook_files; mutable std::map<std::string, std::map<std::string, std::shared_ptr<HookFile> > > auto_hook_files; mutable bool has_auto_hook_files; @@ -482,7 +482,7 @@ namespace paludis void need_auto_hook_files() const { - Lock l(hook_files_mutex); + std::unique_lock<std::recursive_mutex> l(hook_files_mutex); if (has_auto_hook_files) return; @@ -543,7 +543,7 @@ Hooker::~Hooker() void Hooker::add_dir(const FSPath & dir, const bool v) { - Lock l(_imp->hook_files_mutex); + std::unique_lock<std::recursive_mutex> l(_imp->hook_files_mutex); _imp->hook_files.clear(); _imp->auto_hook_files.clear(); _imp->dirs.push_back(std::make_pair(dir, v)); @@ -554,7 +554,7 @@ namespace struct PyHookFileHandle : Singleton<PyHookFileHandle> { - Mutex mutex; + std::mutex mutex; void * handle; std::shared_ptr<HookFile> (* create_py_hook_file_handle)(const FSPath &, const bool, const Environment * const); @@ -630,7 +630,7 @@ Hooker::_find_hooks(const Hook & hook) const static bool load_ok(false); { - Lock lock(PyHookFileHandle::get_instance()->mutex); + std::unique_lock<std::mutex> lock(PyHookFileHandle::get_instance()->mutex); if (! load_try) { @@ -780,7 +780,7 @@ Hooker::perform_hook( /* file hooks, but only if necessary */ - Lock l(_imp->hook_files_mutex); + std::unique_lock<std::recursive_mutex> l(_imp->hook_files_mutex); std::map<std::string, std::shared_ptr<Sequence<std::shared_ptr<HookFile> > > >::iterator h(_imp->hook_files.find(hook.name())); if (h == _imp->hook_files.end()) diff --git a/paludis/ipc_output_manager.cc b/paludis/ipc_output_manager.cc index db3d6f168..df83680a1 100644 --- a/paludis/ipc_output_manager.cc +++ b/paludis/ipc_output_manager.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2010, 2011, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -32,7 +32,6 @@ #include <paludis/util/iterator_funcs.hh> #include <paludis/util/join.hh> #include <paludis/util/pipe.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/options.hh> #include <paludis/standard_output_manager.hh> #include <paludis/create_output_manager_info.hh> @@ -43,6 +42,7 @@ #include <cstdlib> #include <cstring> #include <thread> +#include <mutex> #include <unistd.h> #include <fcntl.h> #include <errno.h> @@ -215,7 +215,7 @@ namespace paludis const Environment * const env; const std::function<void (const std::shared_ptr<OutputManager> &)> on_create; - mutable Mutex mutex; + mutable std::mutex mutex; std::shared_ptr<OutputManager> output_manager; Pipe stdout_pipe, stderr_pipe, finished_pipe; @@ -296,7 +296,7 @@ IPCInputManager::_pipe_command_handler(const std::string & s) << "Got create command, waiting for lock"; { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); Log::get_instance()->message("ipc_input_manager.pipe_command.got_lock", ll_debug, lc_context) << "Got create command, got lock"; @@ -443,7 +443,7 @@ IPCInputManager::_copy_thread() const std::shared_ptr<OutputManager> IPCInputManager::underlying_output_manager_if_constructed() const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); return _imp->output_manager; } diff --git a/paludis/libtool_linkage_checker.cc b/paludis/libtool_linkage_checker.cc index 2251d31b7..5b6969b81 100644 --- a/paludis/libtool_linkage_checker.cc +++ b/paludis/libtool_linkage_checker.cc @@ -23,7 +23,6 @@ #include <paludis/util/config_file.hh> #include <paludis/util/fs_path.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/options.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/stringify.hh> @@ -37,6 +36,7 @@ #include <cerrno> #include <functional> #include <vector> +#include <mutex> using namespace paludis; @@ -49,7 +49,7 @@ namespace paludis { FSPath root; - Mutex mutex; + std::mutex mutex; Breakage breakage; @@ -131,7 +131,7 @@ LibtoolLinkageChecker::check_file(const FSPath & file) ll_debug, lc_context) << "Dependency '" << *it << "' is missing or not a regular file in '" << _imp->root << "'"; - Lock l(_imp->mutex); + std::unique_lock<std::mutex> l(_imp->mutex); _imp->breakage.push_back(std::make_pair(file, *it)); } diff --git a/paludis/ndbam.cc b/paludis/ndbam.cc index 6a6a9b734..987de2712 100644 --- a/paludis/ndbam.cc +++ b/paludis/ndbam.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -61,20 +61,20 @@ namespace { struct CategoryContents { - Mutex mutex; + std::mutex mutex; std::shared_ptr<QualifiedPackageNameSet> package_names; PackageContentsMap package_contents_map; }; struct PackageContents { - Mutex mutex; + std::mutex mutex; std::shared_ptr<NDBAMEntrySequence> entries; }; struct CategoryNamesContainingPackageEntry { - Mutex mutex; + std::mutex mutex; std::shared_ptr<CategoryNamePartSet> category_names_containing_package; }; } @@ -88,11 +88,11 @@ namespace paludis const FSPath location; const VersionSpecOptions version_options; - mutable Mutex category_names_mutex; + mutable std::mutex category_names_mutex; mutable std::shared_ptr<CategoryNamePartSet> category_names; mutable CategoryContentsMap category_contents_map; - mutable Mutex category_names_containing_package_mutex; + mutable std::mutex category_names_containing_package_mutex; mutable CategoryNamesContainingPackage category_names_containing_package; Imp(const FSPath & l, const VersionSpecOptions & o) : @@ -145,7 +145,7 @@ NDBAM::~NDBAM() std::shared_ptr<const CategoryNamePartSet> NDBAM::category_names() { - Lock l(_imp->category_names_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_mutex); if (! _imp->category_names) { Context context("When loading category names for NDBAM at '" + stringify(_imp->location) + "':"); @@ -181,13 +181,13 @@ NDBAM::package_names(const CategoryNamePart & c) if (! has_category_named(c)) return std::make_shared<QualifiedPackageNameSet>(); - Lock l(_imp->category_names_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_mutex); CategoryContentsMap::iterator cc_i(_imp->category_contents_map.find(c)); if (_imp->category_contents_map.end() == cc_i || ! cc_i->second) throw InternalError(PALUDIS_HERE, "has_category_named(" + stringify(c) + ") but got category_contents_map end or zero pointer"); CategoryContents & cc(*cc_i->second); - l.acquire_then_release_old(cc.mutex); + l = std::move(std::unique_lock<std::mutex>(cc.mutex)); if (! cc.package_names) { @@ -220,7 +220,7 @@ NDBAM::package_names(const CategoryNamePart & c) bool NDBAM::has_category_named(const CategoryNamePart & c) { - Lock l(_imp->category_names_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_mutex); CategoryContentsMap::const_iterator it(_imp->category_contents_map.find(c)); if (it != _imp->category_contents_map.end()) return bool(it->second); @@ -244,13 +244,13 @@ NDBAM::has_package_named(const QualifiedPackageName & q) if (! has_category_named(q.category())) return false; - Lock l(_imp->category_names_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_mutex); CategoryContentsMap::iterator cc_i(_imp->category_contents_map.find(q.category())); if (_imp->category_contents_map.end() == cc_i || ! cc_i->second) throw InternalError(PALUDIS_HERE, "has_category_named(" + stringify(q.category()) + ") but got category_contents_map end or zero pointer"); CategoryContents & cc(*cc_i->second); - l.acquire_then_release_old(cc.mutex); + l = std::move(std::unique_lock<std::mutex>(cc.mutex)); PackageContentsMap::const_iterator it(cc.package_contents_map.find(q)); if (it != cc.package_contents_map.end()) @@ -287,18 +287,18 @@ NDBAM::entries(const QualifiedPackageName & q) if (! has_package_named(q)) return std::make_shared<NDBAMEntrySequence>(); - Lock l(_imp->category_names_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_mutex); CategoryContentsMap::iterator cc_i(_imp->category_contents_map.find(q.category())); if (_imp->category_contents_map.end() == cc_i || ! cc_i->second) throw InternalError(PALUDIS_HERE, "has_package_named(" + stringify(q) + ") but got category_contents_map end or zero pointer"); CategoryContents & cc(*cc_i->second); - l.acquire_then_release_old(cc.mutex); + l = std::move(std::unique_lock<std::mutex>(cc.mutex)); PackageContentsMap::iterator pc_i(cc.package_contents_map.find(q)); if (cc.package_contents_map.end() == pc_i || ! pc_i->second) throw InternalError(PALUDIS_HERE, "has_package_named(" + stringify(q) + ") but got package_contents_map end or zero pointer"); PackageContents & pc(*pc_i->second); - l.acquire_then_release_old(pc.mutex); + l = std::move(std::unique_lock<std::mutex>(pc.mutex)); if (! pc.entries) { @@ -329,7 +329,7 @@ NDBAM::entries(const QualifiedPackageName & q) pc.entries->push_back(std::make_shared<NDBAMEntry>(NDBAMEntry(make_named_values<NDBAMEntry>( n::fs_location() = d->realpath(), n::magic() = m, - n::mutex() = std::make_shared<Mutex>(), + n::mutex() = std::make_shared<std::mutex>(), n::name() = q, n::package_id() = std::shared_ptr<PackageID>(), n::slot() = s, @@ -357,18 +357,18 @@ NDBAM::entries(const QualifiedPackageName & q) void NDBAM::add_entry(const QualifiedPackageName & q, const FSPath & d) { - Lock l(_imp->category_names_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_mutex); CategoryContentsMap::iterator cc_i(_imp->category_contents_map.find(q.category())); if (_imp->category_contents_map.end() == cc_i || ! cc_i->second) return; CategoryContents & cc(*cc_i->second); - l.acquire_then_release_old(cc.mutex); + l = std::move(std::unique_lock<std::mutex>(cc.mutex)); PackageContentsMap::iterator pc_i(cc.package_contents_map.find(q)); if (cc.package_contents_map.end() == pc_i || ! pc_i->second) return; PackageContents & pc(*pc_i->second); - l.acquire_then_release_old(pc.mutex); + l = std::move(std::unique_lock<std::mutex>(pc.mutex)); if (pc.entries) { @@ -381,7 +381,7 @@ NDBAM::add_entry(const QualifiedPackageName & q, const FSPath & d) pc.entries->push_back(std::make_shared<NDBAMEntry>(NDBAMEntry(make_named_values<NDBAMEntry>( n::fs_location() = d.realpath(), n::magic() = m, - n::mutex() = std::make_shared<Mutex>(), + n::mutex() = std::make_shared<std::mutex>(), n::name() = q, n::package_id() = std::shared_ptr<PackageID>(), n::slot() = s, @@ -411,18 +411,18 @@ namespace void NDBAM::remove_entry(const QualifiedPackageName & q, const FSPath & d) { - Lock l(_imp->category_names_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_mutex); CategoryContentsMap::iterator cc_i(_imp->category_contents_map.find(q.category())); if (_imp->category_contents_map.end() == cc_i || ! cc_i->second) return; CategoryContents & cc(*cc_i->second); - l.acquire_then_release_old(cc.mutex); + l = std::move(std::unique_lock<std::mutex>(cc.mutex)); PackageContentsMap::iterator pc_i(cc.package_contents_map.find(q)); if (cc.package_contents_map.end() == pc_i || ! pc_i->second) return; PackageContents & pc(*pc_i->second); - l.acquire_then_release_old(pc.mutex); + l = std::move(std::unique_lock<std::mutex>(pc.mutex)); if (pc.entries) { @@ -601,13 +601,13 @@ NDBAM::parse_contents(const PackageID & id, std::shared_ptr<const CategoryNamePartSet> NDBAM::category_names_containing_package(const PackageNamePart & p) const { - Lock l(_imp->category_names_containing_package_mutex); + std::unique_lock<std::mutex> l(_imp->category_names_containing_package_mutex); CategoryNamesContainingPackage::iterator cncp_i(_imp->category_names_containing_package.find(p)); if (_imp->category_names_containing_package.end() == cncp_i) cncp_i = _imp->category_names_containing_package.insert(std::make_pair(p, std::make_shared<CategoryNamesContainingPackageEntry>())).first; CategoryNamesContainingPackageEntry & cncp(*cncp_i->second); - l.acquire_then_release_old(cncp.mutex); + l = std::move(std::unique_lock<std::mutex>(cncp.mutex)); if (! cncp.category_names_containing_package) { Context c("When finding category names containing package '" + stringify(p) + diff --git a/paludis/ndbam.hh b/paludis/ndbam.hh index 07983033d..a3b1e993c 100644 --- a/paludis/ndbam.hh +++ b/paludis/ndbam.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -25,13 +25,13 @@ #include <paludis/util/attributes.hh> #include <paludis/util/fs_path.hh> #include <paludis/util/sequence-fwd.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/named_value.hh> #include <paludis/name.hh> #include <paludis/version_spec.hh> #include <paludis/package_id-fwd.hh> #include <paludis/contents-fwd.hh> #include <functional> +#include <mutex> namespace paludis { @@ -50,7 +50,7 @@ namespace paludis { NamedValue<n::fs_location, FSPath> fs_location; NamedValue<n::magic, std::string> magic; - NamedValue<n::mutex, std::shared_ptr<Mutex> > mutex; + NamedValue<n::mutex, std::shared_ptr<std::mutex> > mutex; NamedValue<n::name, QualifiedPackageName> name; NamedValue<n::package_id, std::shared_ptr<PackageID> > package_id; NamedValue<n::slot, SlotName> slot; diff --git a/paludis/python_hooks.cc b/paludis/python_hooks.cc index ebe800100..e47fc7a58 100644 --- a/paludis/python_hooks.cc +++ b/paludis/python_hooks.cc @@ -10,11 +10,11 @@ #include <paludis/util/stringify.hh> #include <paludis/util/strip.hh> #include <paludis/util/system.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/sequence.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/env_var_names.hh> +#include <mutex> #include <set> using namespace paludis; @@ -32,7 +32,7 @@ namespace public HookFile { private: - static Mutex _mutex; + static std::mutex _mutex; static bp::dict _local_namespace_base; static bp::dict _output_wrapper_namespace; @@ -78,7 +78,7 @@ namespace } }; - Mutex PyHookFile::_mutex; + std::mutex PyHookFile::_mutex; bp::dict PyHookFile::_output_wrapper_namespace; bp::dict PyHookFile::_local_namespace_base; bp::object PyHookFile::_format_exception; @@ -90,7 +90,7 @@ PyHookFile::PyHookFile(const FSPath & f, const bool r, const Environment * const _run_prefixed(r), _loaded(false) { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); static bool initialized(false); @@ -158,7 +158,7 @@ PyHookFile::run(const Hook & hook, const std::shared_ptr<OutputManager> &) const if (! _loaded) return make_named_values<HookResult>(n::max_exit_status() = 0, n::output() = ""); - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); bp::object _run; @@ -243,7 +243,7 @@ PyHookFile::add_dependencies(const Hook & hook, DirectedGraph<std::string, int> if (! _loaded) return; - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); Prefix p(this, _run_prefixed ? strip_trailing_string(file_name().basename(), ".py") + "> " : ""); diff --git a/paludis/repositories/accounts/accounts_id.cc b/paludis/repositories/accounts/accounts_id.cc index 4962665d2..ff985c19c 100644 --- a/paludis/repositories/accounts/accounts_id.cc +++ b/paludis/repositories/accounts/accounts_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -27,7 +27,6 @@ #include <paludis/util/hashes.hh> #include <paludis/util/visitor_cast.hh> #include <paludis/util/tokeniser.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/wrapped_output_iterator.hh> #include <paludis/util/make_null_shared_ptr.hh> @@ -82,7 +81,7 @@ namespace paludis const bool is_user; - mutable Mutex mutex; + mutable std::mutex mutex; mutable bool has_file_keys; mutable bool has_metadata_keys; @@ -135,7 +134,7 @@ AccountsID::~AccountsID() void AccountsID::_add_metadata_keys() const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (_imp->has_metadata_keys) return; @@ -177,7 +176,7 @@ AccountsID::_need_file_keys() const if (_imp->has_file_keys) return; - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); KeyValueConfigFile k(_imp->fs_location_key->parse_value(), { }, &KeyValueConfigFile::no_defaults, &KeyValueConfigFile::no_transformation); @@ -252,7 +251,7 @@ AccountsID::need_keys_added() const void AccountsID::clear_metadata_keys() const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->has_metadata_keys = false; PackageID::clear_metadata_keys(); } diff --git a/paludis/repositories/accounts/installed_accounts_id.cc b/paludis/repositories/accounts/installed_accounts_id.cc index 1457d8b93..f0babf6fb 100644 --- a/paludis/repositories/accounts/installed_accounts_id.cc +++ b/paludis/repositories/accounts/installed_accounts_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -27,7 +27,6 @@ #include <paludis/util/visitor_cast.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/make_named_values.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/log.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/singleton-impl.hh> @@ -78,7 +77,7 @@ namespace paludis const RepositoryName repository_name; const std::shared_ptr<const LiteralMetadataStringSetKey> behaviours_key; - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::shared_ptr<const AccountsDepKey> dependencies_key; const bool is_user; @@ -111,7 +110,7 @@ InstalledAccountsID::~InstalledAccountsID() void InstalledAccountsID::need_keys_added() const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (_imp->is_user && ! _imp->dependencies_key) { diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index 0d1728abe..66650eeaa 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -33,7 +33,6 @@ #include <paludis/util/log.hh> #include <paludis/util/visitor_cast.hh> #include <paludis/util/make_null_shared_ptr.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/singleton-impl.hh> #include <paludis/elike_dep_parser.hh> #include <paludis/elike_conditional_dep_spec.hh> diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc index e250f11c1..09df36b38 100644 --- a/paludis/repositories/e/e_choices_key.cc +++ b/paludis/repositories/e/e_choices_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -28,7 +28,6 @@ #include <paludis/util/pimp-impl.hh> #include <paludis/util/stringify.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/join.hh> #include <paludis/util/visitor_cast.hh> #include <paludis/util/tribool.hh> @@ -47,10 +46,11 @@ #include <paludis/elike_choices.hh> #include <paludis/dep_spec_annotations.hh> -#include <list> #include <algorithm> -#include <set> +#include <list> #include <map> +#include <mutex> +#include <set> using namespace paludis; using namespace paludis::erepository; @@ -60,7 +60,7 @@ namespace paludis template <> struct Imp<EChoicesKey> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::shared_ptr<Choices> value; const Environment * const env; @@ -278,7 +278,7 @@ namespace const std::shared_ptr<const Choices> EChoicesKey::parse_value() const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (_imp->value) return _imp->value; diff --git a/paludis/repositories/e/e_installed_repository.cc b/paludis/repositories/e/e_installed_repository.cc index 7092794b5..2632c1951 100644 --- a/paludis/repositories/e/e_installed_repository.cc +++ b/paludis/repositories/e/e_installed_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -27,7 +27,6 @@ #include <paludis/util/visitor_cast.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/util/log.hh> #include <paludis/util/set.hh> @@ -67,7 +66,6 @@ namespace paludis struct Imp<EInstalledRepository> { EInstalledRepositoryParams params; - Mutex world_mutex; Imp(const EInstalledRepositoryParams & p) : params(p) diff --git a/paludis/repositories/e/e_installed_repository_id.cc b/paludis/repositories/e/e_installed_repository_id.cc index 899cb402d..8a2f9fd02 100644 --- a/paludis/repositories/e/e_installed_repository_id.cc +++ b/paludis/repositories/e/e_installed_repository_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -32,7 +32,6 @@ #include <paludis/util/log.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/strip.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/safe_ifstream.hh> #include <paludis/util/make_named_values.hh> @@ -145,7 +144,7 @@ namespace paludis template <> struct Imp<EInstalledRepositoryID> { - mutable Mutex mutex; + mutable std::recursive_mutex mutex; const QualifiedPackageName name; const VersionSpec version; @@ -187,7 +186,7 @@ EInstalledRepositoryID::~EInstalledRepositoryID() void EInstalledRepositoryID::need_keys_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if (_imp->keys) return; @@ -678,7 +677,7 @@ EInstalledRepositoryID::repository_name() const const std::shared_ptr<const EAPI> EInstalledRepositoryID::eapi() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if (_imp->eapi) return _imp->eapi; @@ -885,7 +884,7 @@ EInstalledRepositoryID::fs_location_key() const // Avoid loading whole metadata if (! _imp->fs_location) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->fs_location = std::make_shared<LiteralMetadataValueKey<FSPath> >(fs_location_raw_name(), fs_location_human_name(), mkt_internal, _imp->dir); @@ -1089,7 +1088,7 @@ EInstalledRepositoryID::purge_invalid_cache() const void EInstalledRepositoryID::can_drop_in_memory_cache() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); clear_metadata_keys(); _imp->keys.reset(); diff --git a/paludis/repositories/e/e_keywords_key.cc b/paludis/repositories/e/e_keywords_key.cc index 07933b390..d5f0c1415 100644 --- a/paludis/repositories/e/e_keywords_key.cc +++ b/paludis/repositories/e/e_keywords_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2011 Ciaran McCreesh + * Copyright (c) 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -131,7 +131,7 @@ namespace paludis template <> struct Imp<EKeywordsKeyStore> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::unordered_map<EKeywordsKeyStoreIndex, std::shared_ptr<const EKeywordsKey>, EKeywordsKeyHash, EKeywordsKeyStoreCompare> store; }; } @@ -149,7 +149,7 @@ EKeywordsKeyStore::fetch( const std::string & s, const MetadataKeyType t) const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); auto k(std::make_shared<Set<KeywordName> >()); tokenise_whitespace(s, create_inserter<KeywordName>(k->inserter())); diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc index dc29c64ca..ba0e2a7ed 100644 --- a/paludis/repositories/e/e_repository.cc +++ b/paludis/repositories/e/e_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * Copyright (c) 2006 Danny van Dyk * * This file is part of the Paludis package manager. Paludis is free software; @@ -82,7 +82,6 @@ #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/make_shared_copy.hh> #include <paludis/util/map.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/options.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/process.hh> @@ -200,12 +199,12 @@ namespace paludis { struct Mutexes { - Mutex arch_flags_mutex; - Mutex mirrors_mutex; - Mutex use_desc_mutex; - Mutex profile_ptr_mutex; - Mutex news_ptr_mutex; - Mutex eapi_for_file_mutex; + std::mutex arch_flags_mutex; + std::mutex mirrors_mutex; + std::mutex use_desc_mutex; + std::mutex profile_ptr_mutex; + std::mutex news_ptr_mutex; + std::mutex eapi_for_file_mutex; }; ERepository * const repo; @@ -421,7 +420,7 @@ namespace paludis void Imp<ERepository>::need_profiles() const { - Lock l(mutexes->profile_ptr_mutex); + std::unique_lock<std::mutex> l(mutexes->profile_ptr_mutex); if (profile_ptr) return; @@ -633,7 +632,7 @@ ERepository::package_ids(const QualifiedPackageName & n, const RepositoryContent const std::shared_ptr<const Set<UnprefixedChoiceName> > ERepository::arch_flags() const { - Lock l(_imp->mutexes->arch_flags_mutex); + std::unique_lock<std::mutex> l(_imp->mutexes->arch_flags_mutex); if (! _imp->arch_flags) { Context context("When loading arch list:"); @@ -679,7 +678,7 @@ namespace void ERepository::need_mirrors() const { - Lock l(_imp->mutexes->mirrors_mutex); + std::unique_lock<std::mutex> l(_imp->mutexes->mirrors_mutex); if (! _imp->has_mirrors) { @@ -850,7 +849,7 @@ ERepository::purge_invalid_cache() const void ERepository::update_news() const { - Lock l(_imp->mutexes->news_ptr_mutex); + std::unique_lock<std::mutex> l(_imp->mutexes->news_ptr_mutex); if (! _imp->news_ptr) _imp->news_ptr = std::make_shared<ERepositoryNews>(_imp->params.environment(), this, _imp->params); @@ -1594,7 +1593,7 @@ ERepository::repository_factory_dependencies( const std::shared_ptr<const UseDesc> ERepository::use_desc() const { - Lock l(_imp->mutexes->use_desc_mutex); + std::unique_lock<std::mutex> l(_imp->mutexes->use_desc_mutex); if (! _imp->use_desc) { _imp->use_desc = std::make_shared<UseDesc>(_imp->layout->use_desc_files()); @@ -1607,7 +1606,7 @@ const std::string ERepository::eapi_for_file(const FSPath & f) const { FSPath dir(f.dirname()); - Lock lock(_imp->mutexes->eapi_for_file_mutex); + std::unique_lock<std::mutex> lock(_imp->mutexes->eapi_for_file_mutex); EAPIForFileMap::const_iterator i(_imp->eapi_for_file_map.find(dir)); if (i == _imp->eapi_for_file_map.end()) { diff --git a/paludis/repositories/e/e_slot_key.cc b/paludis/repositories/e/e_slot_key.cc index f97fb22d4..4ecdbae03 100644 --- a/paludis/repositories/e/e_slot_key.cc +++ b/paludis/repositories/e/e_slot_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2010, 2011, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -97,7 +97,7 @@ namespace paludis template <> struct Imp<ESlotKeyStore> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::unordered_map<ESlotKeyStoreIndex, std::shared_ptr<const ESlotKey>, ESlotKeyStoreHash> store; }; } @@ -127,7 +127,7 @@ ESlotKeyStore::fetch( } } - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); ESlotKeyStoreIndex x(v, ss, mkt); auto i(_imp->store.find(x)); diff --git a/paludis/repositories/e/e_string_set_key.cc b/paludis/repositories/e/e_string_set_key.cc index b2cde9a24..0252666e0 100644 --- a/paludis/repositories/e/e_string_set_key.cc +++ b/paludis/repositories/e/e_string_set_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2011 Ciaran McCreesh + * Copyright (c) 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -130,7 +130,7 @@ namespace paludis template <> struct Imp<EStringSetKeyStore> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::unordered_map<EStringSetKeyStoreIndex, std::shared_ptr<const EStringSetKey>, EStringSetKeyHash, EStringSetKeyStoreCompare> store; }; } @@ -148,7 +148,7 @@ EStringSetKeyStore::fetch( const std::string & s, const MetadataKeyType t) const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); auto k(std::make_shared<Set<std::string> >()); tokenise_whitespace(s, k->inserter()); diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc index 51781cc59..cdc8f8088 100644 --- a/paludis/repositories/e/ebuild_id.cc +++ b/paludis/repositories/e/ebuild_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -54,7 +54,6 @@ #include <paludis/util/fs_error.hh> #include <paludis/util/stringify.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/save.hh> #include <paludis/util/make_named_values.hh> @@ -135,7 +134,7 @@ namespace paludis template <> struct Imp<EbuildID> { - mutable Mutex mutex; + mutable std::recursive_mutex mutex; const QualifiedPackageName name; const VersionSpec version; @@ -230,7 +229,7 @@ EbuildID::~EbuildID() void EbuildID::need_non_xml_keys_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if (_imp->has_non_xml_keys) return; @@ -499,7 +498,7 @@ EbuildID::presource_eapi() const void EbuildID::need_xml_keys_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if (_imp->has_xml_keys) return; @@ -530,7 +529,7 @@ EbuildID::need_xml_keys_added() const void EbuildID::need_keys_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); need_non_xml_keys_added(); need_xml_keys_added(); @@ -619,7 +618,7 @@ namespace void EbuildID::need_masks_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if (_imp->has_masks) return; @@ -996,7 +995,7 @@ EbuildID::extra_hash_value() const void EbuildID::set_eapi(const std::string & s) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->eapi = EAPIData::get_instance()->eapi_from_string(s); } @@ -1009,7 +1008,7 @@ EbuildID::guessed_eapi_name() const void EbuildID::load_captured_stderr(const std::string & r, const std::string & h, const MetadataKeyType t, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->captured_stderr_key = std::make_shared<LiteralMetadataValueKey<std::string> >(r, h, t, v); add_metadata_key(_imp->captured_stderr_key); } @@ -1017,7 +1016,7 @@ EbuildID::load_captured_stderr(const std::string & r, const std::string & h, con void EbuildID::load_captured_stdout(const std::string & r, const std::string & h, const MetadataKeyType t, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->captured_stdout_key = std::make_shared<LiteralMetadataValueKey<std::string> >(r, h, t, v); add_metadata_key(_imp->captured_stdout_key); } @@ -1025,7 +1024,7 @@ EbuildID::load_captured_stdout(const std::string & r, const std::string & h, con void EbuildID::load_short_description(const std::string & r, const std::string & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->short_description = std::make_shared<LiteralMetadataValueKey<std::string> >(r, h, mkt_significant, v); add_metadata_key(_imp->short_description); } @@ -1033,7 +1032,7 @@ EbuildID::load_short_description(const std::string & r, const std::string & h, c void EbuildID::load_long_description(const std::string & r, const std::string & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->long_description = std::make_shared<LiteralMetadataValueKey<std::string> >(r, h, mkt_normal, v); add_metadata_key(_imp->long_description); } @@ -1043,7 +1042,7 @@ EbuildID::load_dependencies(const std::string & r, const std::string & h, const { if (! strip_leading(v, " \t\r\n").empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v, EbuildIDData::get_instance()->raw_dependencies_labels, mkt_dependencies); add_metadata_key(_imp->dependencies); @@ -1056,7 +1055,7 @@ EbuildID::load_build_depend(const std::string & r, const std::string & h, const { if (! strip_leading(v, " \t\r\n").empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->build_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v, EbuildIDData::get_instance()->build_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies); add_metadata_key(_imp->build_dependencies); @@ -1069,7 +1068,7 @@ EbuildID::load_run_depend(const std::string & r, const std::string & h, const st { if (! strip_leading(v, " \t\r\n").empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->run_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v, EbuildIDData::get_instance()->run_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies); add_metadata_key(_imp->run_dependencies); @@ -1082,7 +1081,7 @@ EbuildID::load_post_depend(const std::string & r, const std::string & h, const s { if (! strip_leading(v, " \t\r\n").empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->post_dependencies = std::make_shared<EDependenciesKey>(_imp->environment, shared_from_this(), r, h, v, EbuildIDData::get_instance()->post_dependencies_labels, rewritten ? mkt_internal : mkt_dependencies); add_metadata_key(_imp->post_dependencies); @@ -1092,7 +1091,7 @@ EbuildID::load_post_depend(const std::string & r, const std::string & h, const s void EbuildID::load_src_uri(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->src_uri = std::make_shared<EFetchableURIKey>(_imp->environment, shared_from_this(), m, v, mkt_dependencies); add_metadata_key(_imp->src_uri); } @@ -1100,7 +1099,7 @@ EbuildID::load_src_uri(const std::shared_ptr<const EAPIMetadataVariable> & m, co void EbuildID::load_homepage(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->homepage = std::make_shared<ESimpleURIKey>(_imp->environment, m, eapi(), v, mkt_significant, is_installed()); add_metadata_key(_imp->homepage); } @@ -1108,7 +1107,7 @@ EbuildID::load_homepage(const std::shared_ptr<const EAPIMetadataVariable> & m, c void EbuildID::load_license(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->license = std::make_shared<ELicenseKey>(_imp->environment, m, eapi(), v, mkt_internal, is_installed()); add_metadata_key(_imp->license); } @@ -1118,7 +1117,7 @@ EbuildID::load_restrict(const std::shared_ptr<const EAPIMetadataVariable> & m, c { if (! strip_leading(v, " \t\r\n").empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->restrictions = std::make_shared<EPlainTextSpecKey>(_imp->environment, m, eapi(), v, mkt_internal, is_installed()); add_metadata_key(_imp->restrictions); } @@ -1129,7 +1128,7 @@ EbuildID::load_properties(const std::shared_ptr<const EAPIMetadataVariable> & m, { if (! strip_leading(v, " \t\r\n").empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->properties = std::make_shared<EPlainTextSpecKey>(_imp->environment, m, eapi(), v, mkt_internal, is_installed()); add_metadata_key(_imp->properties); } @@ -1138,7 +1137,7 @@ EbuildID::load_properties(const std::shared_ptr<const EAPIMetadataVariable> & m, void EbuildID::load_iuse(const std::shared_ptr<const EAPIMetadataVariable> & k, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->raw_iuse = EStringSetKeyStore::get_instance()->fetch(k, v, mkt_internal); add_metadata_key(_imp->raw_iuse); } @@ -1146,7 +1145,7 @@ EbuildID::load_iuse(const std::shared_ptr<const EAPIMetadataVariable> & k, const void EbuildID::load_myoptions(const std::shared_ptr<const EAPIMetadataVariable> & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->raw_myoptions = std::make_shared<EMyOptionsKey>(_imp->environment, h, eapi(), v, mkt_internal, is_installed()); add_metadata_key(_imp->raw_myoptions); } @@ -1156,7 +1155,7 @@ EbuildID::load_required_use(const std::shared_ptr<const EAPIMetadataVariable> & { if (! strip_leading(v, " \t\r\n").empty()) { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->required_use = std::make_shared<ERequiredUseKey>(_imp->environment, k, eapi(), v, mkt_internal, is_installed()); add_metadata_key(_imp->required_use); } @@ -1165,7 +1164,7 @@ EbuildID::load_required_use(const std::shared_ptr<const EAPIMetadataVariable> & void EbuildID::load_use(const std::shared_ptr<const EAPIMetadataVariable> & r, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->raw_use = EStringSetKeyStore::get_instance()->fetch(r, v, mkt_internal); add_metadata_key(_imp->raw_use); } @@ -1173,7 +1172,7 @@ EbuildID::load_use(const std::shared_ptr<const EAPIMetadataVariable> & r, const void EbuildID::load_keywords(const std::shared_ptr<const EAPIMetadataVariable> & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->keywords = EKeywordsKeyStore::get_instance()->fetch(h, v, mkt_internal); add_metadata_key(_imp->keywords); } @@ -1181,7 +1180,7 @@ EbuildID::load_keywords(const std::shared_ptr<const EAPIMetadataVariable> & h, c void EbuildID::load_inherited(const std::shared_ptr<const EAPIMetadataVariable> & r, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->inherited = EStringSetKeyStore::get_instance()->fetch(r, v, mkt_internal); add_metadata_key(_imp->inherited); } @@ -1192,7 +1191,7 @@ EbuildID::load_defined_phases(const std::shared_ptr<const EAPIMetadataVariable> if (strip_leading(v, " \t\r\n").empty()) throw InternalError(PALUDIS_HERE, "v should not be empty"); - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->defined_phases = EStringSetKeyStore::get_instance()->fetch(h, v, mkt_internal); add_metadata_key(_imp->defined_phases); } @@ -1200,7 +1199,7 @@ EbuildID::load_defined_phases(const std::shared_ptr<const EAPIMetadataVariable> void EbuildID::load_upstream_changelog(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->upstream_changelog = std::make_shared<ESimpleURIKey>(_imp->environment, m, eapi(), v, mkt_normal, is_installed()); add_metadata_key(_imp->upstream_changelog); } @@ -1208,7 +1207,7 @@ EbuildID::load_upstream_changelog(const std::shared_ptr<const EAPIMetadataVariab void EbuildID::load_upstream_documentation(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->upstream_documentation = std::make_shared<ESimpleURIKey>(_imp->environment, m, eapi(), v, mkt_normal, is_installed()); add_metadata_key(_imp->upstream_documentation); } @@ -1216,7 +1215,7 @@ EbuildID::load_upstream_documentation(const std::shared_ptr<const EAPIMetadataVa void EbuildID::load_upstream_release_notes(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->upstream_release_notes = std::make_shared<ESimpleURIKey>(_imp->environment, m, eapi(), v, mkt_normal, is_installed()); add_metadata_key(_imp->upstream_release_notes); } @@ -1224,7 +1223,7 @@ EbuildID::load_upstream_release_notes(const std::shared_ptr<const EAPIMetadataVa void EbuildID::load_bugs_to(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->bugs_to = std::make_shared<EPlainTextSpecKey>(_imp->environment, m, eapi(), v, mkt_normal, is_installed()); add_metadata_key(_imp->bugs_to); } @@ -1232,7 +1231,7 @@ EbuildID::load_bugs_to(const std::shared_ptr<const EAPIMetadataVariable> & m, co void EbuildID::load_remote_ids(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->remote_ids = std::make_shared<EPlainTextSpecKey>(_imp->environment, m, eapi(), v, mkt_internal, is_installed()); add_metadata_key(_imp->remote_ids); } @@ -1240,7 +1239,7 @@ EbuildID::load_remote_ids(const std::shared_ptr<const EAPIMetadataVariable> & m, void EbuildID::load_slot(const std::shared_ptr<const EAPIMetadataVariable> & m, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->slot = ESlotKeyStore::get_instance()->fetch(*eapi(), m, v, mkt_internal); add_metadata_key(_imp->slot); } @@ -1248,7 +1247,7 @@ EbuildID::load_slot(const std::shared_ptr<const EAPIMetadataVariable> & m, const void EbuildID::load_generated_from(const std::shared_ptr<const EAPIMetadataVariable> & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->generated_from = EStringSetKeyStore::get_instance()->fetch(h, v, mkt_normal); add_metadata_key(_imp->generated_from); } @@ -1256,7 +1255,7 @@ EbuildID::load_generated_from(const std::shared_ptr<const EAPIMetadataVariable> void EbuildID::load_generated_time(const std::string & r, const std::string & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->generated_time = std::make_shared<LiteralMetadataTimeKey>(r, h, mkt_normal, Timestamp(destringify<std::time_t>(v), 0)); add_metadata_key(_imp->generated_time); } @@ -1264,7 +1263,7 @@ EbuildID::load_generated_time(const std::string & r, const std::string & h, cons void EbuildID::load_generated_using(const std::string & r, const std::string & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->generated_using = std::make_shared<LiteralMetadataValueKey<std::string> >(r, h, mkt_normal, v); add_metadata_key(_imp->generated_using); } @@ -1272,7 +1271,7 @@ EbuildID::load_generated_using(const std::string & r, const std::string & h, con void EbuildID::load_scm_revision(const std::string & r, const std::string & h, const std::string & v) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); _imp->scm_revision = std::make_shared<LiteralMetadataValueKey<std::string> >(r, h, mkt_normal, v); add_metadata_key(_imp->scm_revision); } @@ -1785,7 +1784,7 @@ EbuildID::is_installed() const void EbuildID::set_scm_revision(const std::string & s) const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if ((! eapi()->supported()) || eapi()->supported()->ebuild_metadata_variables()->scm_revision()->name().empty() || diff --git a/paludis/repositories/e/eclass_mtimes.cc b/paludis/repositories/e/eclass_mtimes.cc index c2474769a..2ce163f98 100644 --- a/paludis/repositories/e/eclass_mtimes.cc +++ b/paludis/repositories/e/eclass_mtimes.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2010, 2011, 2013 Ciaran McCreesh * Copyright (c) 2008, 2012 David Leverton * * This file is part of the Paludis package manager. Paludis is free software; @@ -24,12 +24,12 @@ #include <paludis/name.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/hashes.hh> #include <paludis/util/fs_stat.hh> #include <paludis/util/md5.hh> #include <paludis/util/safe_ifstream.hh> +#include <mutex> #include <unordered_map> using namespace paludis; @@ -77,7 +77,7 @@ namespace paludis mutable Cache eclasses; mutable std::unordered_map<QualifiedPackageName, Cache, Hash<QualifiedPackageName> > exlibs; mutable MD5Map md5s; - mutable Mutex mutex; + mutable std::mutex mutex; Imp(const ERepository * r, const std::shared_ptr<const FSPathSequence> & d) : repo(r), @@ -99,14 +99,14 @@ EclassMtimes::~EclassMtimes() const std::pair<FSPath, FSStat> * EclassMtimes::eclass(const std::string & e) const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); return lookup(e + ".eclass", _imp->eclasses); } const std::pair<FSPath, FSStat> * EclassMtimes::exlib(const std::string & e, const QualifiedPackageName & qpn) const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); std::unordered_map<QualifiedPackageName, Cache, Hash<QualifiedPackageName> >::iterator cache(_imp->exlibs.find(qpn)); if (_imp->exlibs.end() == cache) cache = _imp->exlibs.insert(std::make_pair(qpn, Cache(_imp->repo->layout()->exlibsdirs(qpn)))).first; @@ -116,7 +116,7 @@ EclassMtimes::exlib(const std::string & e, const QualifiedPackageName & qpn) con std::string EclassMtimes::md5(const FSPath & p) const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); MD5Map::const_iterator it(_imp->md5s.find(p)); if (_imp->md5s.end() != it) return it->second; diff --git a/paludis/repositories/e/exheres_layout.cc b/paludis/repositories/e/exheres_layout.cc index 7891ce504..4be51e146 100644 --- a/paludis/repositories/e/exheres_layout.cc +++ b/paludis/repositories/e/exheres_layout.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -30,7 +30,6 @@ #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/log.hh> #include <paludis/util/map.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/util/is_file_with_extension.hh> #include <paludis/util/wrapped_output_iterator.hh> @@ -79,7 +78,7 @@ namespace paludis const ERepository * const repository; const FSPath tree_root; - mutable Mutex big_nasty_mutex; + mutable std::recursive_mutex big_nasty_mutex; mutable bool has_category_names; mutable CategoryMap category_names; @@ -190,7 +189,7 @@ ExheresLayout::categories_file() const void ExheresLayout::need_category_names() const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); if (_imp->has_category_names) return; @@ -240,7 +239,7 @@ ExheresLayout::need_category_names() const void ExheresLayout::need_package_ids(const QualifiedPackageName & n) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); using namespace std::placeholders; @@ -290,7 +289,7 @@ ExheresLayout::need_package_ids(const QualifiedPackageName & n) const bool ExheresLayout::has_category_named(const CategoryNamePart & c) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When checking for category '" + stringify(c) + "' in '" + stringify(_imp->repository->name()) + "':"); @@ -301,7 +300,7 @@ ExheresLayout::has_category_named(const CategoryNamePart & c) const bool ExheresLayout::has_package_named(const QualifiedPackageName & q) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When checking for package '" + stringify(q) + "' in '" + stringify(_imp->repository->name()) + ":"); @@ -337,7 +336,7 @@ ExheresLayout::has_package_named(const QualifiedPackageName & q) const void ExheresLayout::need_category_names_collection() const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); if (_imp->category_names_collection) return; @@ -353,7 +352,7 @@ ExheresLayout::need_category_names_collection() const std::shared_ptr<const CategoryNamePartSet> ExheresLayout::category_names() const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When fetching category names in " + stringify(stringify(_imp->repository->name())) + ":"); @@ -364,7 +363,7 @@ ExheresLayout::category_names() const std::shared_ptr<const QualifiedPackageNameSet> ExheresLayout::package_names(const CategoryNamePart & c) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); using namespace std::placeholders; @@ -414,7 +413,7 @@ ExheresLayout::package_names(const CategoryNamePart & c) const std::shared_ptr<const PackageIDSequence> ExheresLayout::package_ids(const QualifiedPackageName & n) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When fetching versions of '" + stringify(n) + "' in " + stringify(_imp->repository->name()) + ":"); diff --git a/paludis/repositories/e/exheres_profile.cc b/paludis/repositories/e/exheres_profile.cc index 67d23c0f9..de84491a7 100644 --- a/paludis/repositories/e/exheres_profile.cc +++ b/paludis/repositories/e/exheres_profile.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -30,7 +30,6 @@ #include <paludis/util/wrapped_output_iterator.hh> #include <paludis/util/config_file.hh> #include <paludis/util/map.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/set.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/hashes.hh> diff --git a/paludis/repositories/e/exndbam_id.cc b/paludis/repositories/e/exndbam_id.cc index ab2b651c7..7cc85065c 100644 --- a/paludis/repositories/e/exndbam_id.cc +++ b/paludis/repositories/e/exndbam_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -18,7 +18,6 @@ */ #include <paludis/repositories/e/exndbam_id.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> diff --git a/paludis/repositories/e/exndbam_repository.cc b/paludis/repositories/e/exndbam_repository.cc index d3c76436e..7064b2f95 100644 --- a/paludis/repositories/e/exndbam_repository.cc +++ b/paludis/repositories/e/exndbam_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -54,6 +54,7 @@ #include <paludis/slot.hh> #include <functional> +#include <mutex> using namespace paludis; using namespace paludis::erepository; @@ -212,7 +213,7 @@ ExndbamRepository::package_ids(const QualifiedPackageName & q, for (IndirectIterator<NDBAMEntrySequence::ConstIterator> e(entries->begin()), e_end(entries->end()) ; e != e_end ; ++e) { - Lock l(*(*e).mutex()); + std::unique_lock<std::mutex> l(*(*e).mutex()); if (! (*e).package_id()) (*e).package_id() = std::make_shared<ExndbamID>((*e).name(), (*e).version(), _imp->params.environment(), name(), (*e).fs_location(), &_imp->ndbam); diff --git a/paludis/repositories/e/glsa.cc b/paludis/repositories/e/glsa.cc index c9a883c05..ce904ed58 100644 --- a/paludis/repositories/e/glsa.cc +++ b/paludis/repositories/e/glsa.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -21,7 +21,6 @@ #include <paludis/repositories/e/xml_things_handle.hh> #include <paludis/util/stringify.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/about.hh> diff --git a/paludis/repositories/e/info_metadata_key.cc b/paludis/repositories/e/info_metadata_key.cc index 6b1be734f..f90ad2585 100644 --- a/paludis/repositories/e/info_metadata_key.cc +++ b/paludis/repositories/e/info_metadata_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -22,7 +22,6 @@ #include <paludis/repositories/e/e_repository.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/config_file.hh> #include <paludis/util/stringify.hh> #include <paludis/util/options.hh> @@ -48,6 +47,7 @@ #include <map> #include <algorithm> #include <functional> +#include <mutex> using namespace paludis; using namespace paludis::erepository; @@ -59,7 +59,7 @@ namespace paludis { const std::shared_ptr<const FSPathSequence> locations; - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::shared_ptr<Set<std::string> > value; Imp(const std::shared_ptr<const FSPathSequence> & l) : @@ -75,7 +75,7 @@ namespace paludis const std::shared_ptr<const FSPathSequence> locations; const ERepository * const e_repository; - mutable Mutex mutex; + mutable std::mutex mutex; mutable bool added; Imp(const Environment * const e, const std::shared_ptr<const FSPathSequence> & l, @@ -101,7 +101,7 @@ InfoVarsMetadataKey::~InfoVarsMetadataKey() const std::shared_ptr<const Set<std::string> > InfoVarsMetadataKey::parse_value() const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (_imp->value) return _imp->value; @@ -156,7 +156,7 @@ InfoPkgsMetadataKey::~InfoPkgsMetadataKey() void InfoPkgsMetadataKey::need_keys_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (_imp->added) return; diff --git a/paludis/repositories/e/memoised_hashes.cc b/paludis/repositories/e/memoised_hashes.cc index a72c88fd7..290790856 100644 --- a/paludis/repositories/e/memoised_hashes.cc +++ b/paludis/repositories/e/memoised_hashes.cc @@ -19,7 +19,6 @@ #include <paludis/repositories/e/memoised_hashes.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/singleton-impl.hh> #include <paludis/util/safe_ifstream.hh> @@ -40,7 +39,7 @@ namespace paludis template <> struct Imp<MemoisedHashes> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable HashesMap hashes; Imp() @@ -64,7 +63,7 @@ MemoisedHashes::get(const std::string & algo, const FSPath & file, SafeIFStream std::pair<std::string, std::string> key(stringify(file), algo); Timestamp mtime(file.stat().mtim()); - Lock l(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); HashesMap::iterator i(_imp->hashes.find(key)); diff --git a/paludis/repositories/e/metadata_xml.cc b/paludis/repositories/e/metadata_xml.cc index 73d22ba63..216ab0a35 100644 --- a/paludis/repositories/e/metadata_xml.cc +++ b/paludis/repositories/e/metadata_xml.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -22,7 +22,6 @@ #include <paludis/util/pimp-impl.hh> #include <paludis/util/singleton-impl.hh> #include <paludis/util/map-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/log.hh> #include <paludis/util/fs_path.hh> @@ -41,7 +40,7 @@ namespace paludis template <> struct Imp<MetadataXMLPool> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable Store store; }; } @@ -61,7 +60,7 @@ MetadataXMLPool::metadata_if_exists(const FSPath & f) const Context context("When handling metadata.xml file '" + stringify(f) + "':"); FSPath f_real(f.realpath_if_exists()); - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); Store::const_iterator i(_imp->store.find(f_real)); if (i != _imp->store.end()) return i->second; diff --git a/paludis/repositories/e/parse_dependency_label.cc b/paludis/repositories/e/parse_dependency_label.cc index 6ab886654..9f4588858 100644 --- a/paludis/repositories/e/parse_dependency_label.cc +++ b/paludis/repositories/e/parse_dependency_label.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -22,7 +22,6 @@ #include <paludis/repositories/e/eapi.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/singleton-impl.hh> @@ -99,7 +98,7 @@ namespace struct DepLabelsStore : Singleton<DepLabelsStore> { - Mutex mutex; + std::mutex mutex; std::map<DepLabelsIndex, std::shared_ptr<DependenciesLabel> > store; std::shared_ptr<DependenciesLabel> make(const std::string & class_name, const std::string & text) @@ -137,7 +136,7 @@ namespace std::shared_ptr<DependenciesLabel> get(const std::string & eapi_name, const std::string & class_name, const std::string & text) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); DepLabelsIndex x{eapi_name, class_name, text}; auto i(store.find(x)); @@ -149,7 +148,7 @@ namespace std::shared_ptr<DependenciesLabel> get_test(const std::string & eapi_name, const std::string & class_name, const ChoiceNameWithPrefix & choice_name, const std::string & text) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); DepLabelsIndex x{eapi_name, class_name, stringify(choice_name) + "/" + text}; auto i(store.find(x)); diff --git a/paludis/repositories/e/parse_plain_text_label.cc b/paludis/repositories/e/parse_plain_text_label.cc index 1055e698b..ce0a83c5a 100644 --- a/paludis/repositories/e/parse_plain_text_label.cc +++ b/paludis/repositories/e/parse_plain_text_label.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -21,7 +21,6 @@ #include <paludis/repositories/e/dep_parser.hh> #include <paludis/repositories/e/eapi.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/singleton-impl.hh> #include <paludis/dep_label.hh> diff --git a/paludis/repositories/e/parse_uri_label.cc b/paludis/repositories/e/parse_uri_label.cc index 4f2ef7bb9..55e4391be 100644 --- a/paludis/repositories/e/parse_uri_label.cc +++ b/paludis/repositories/e/parse_uri_label.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -21,7 +21,6 @@ #include <paludis/repositories/e/dep_parser.hh> #include <paludis/repositories/e/eapi.hh> #include <paludis/util/log.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/singleton-impl.hh> #include <paludis/dep_label.hh> @@ -39,7 +38,7 @@ namespace struct URILabelsStore : Singleton<URILabelsStore> { - Mutex mutex; + std::mutex mutex; std::map<URILabelsIndex, std::shared_ptr<URILabel> > store; std::shared_ptr<URILabel> make(const std::string & class_name, const std::string & text) @@ -62,7 +61,7 @@ namespace std::shared_ptr<URILabel> get(const std::string & eapi_name, const std::string & class_name, const std::string & text) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); URILabelsIndex x{eapi_name, class_name, text}; auto i(store.find(x)); diff --git a/paludis/repositories/e/traditional_layout.cc b/paludis/repositories/e/traditional_layout.cc index 41c5888f8..5ca63317c 100644 --- a/paludis/repositories/e/traditional_layout.cc +++ b/paludis/repositories/e/traditional_layout.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * Copyright (c) 2006 Danny van Dyk * * This file is part of the Paludis package manager. Paludis is free software; @@ -33,7 +33,6 @@ #include <paludis/util/strip.hh> #include <paludis/util/sequence.hh> #include <paludis/util/wrapped_output_iterator.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/set.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/hashes.hh> @@ -79,7 +78,7 @@ namespace paludis const ERepository * const repository; const FSPath tree_root; - mutable Mutex big_nasty_mutex; + mutable std::recursive_mutex big_nasty_mutex; mutable bool has_category_names; mutable CategoryMap category_names; @@ -188,7 +187,7 @@ TraditionalLayout::categories_file() const void TraditionalLayout::need_category_names() const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); if (_imp->has_category_names) return; @@ -259,7 +258,7 @@ TraditionalLayout::need_category_names() const void TraditionalLayout::need_package_ids(const QualifiedPackageName & n) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); using namespace std::placeholders; @@ -309,7 +308,7 @@ TraditionalLayout::need_package_ids(const QualifiedPackageName & n) const bool TraditionalLayout::has_category_named(const CategoryNamePart & c) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When checking for category '" + stringify(c) + "' in '" + stringify(_imp->repository->name()) + "':"); @@ -320,7 +319,7 @@ TraditionalLayout::has_category_named(const CategoryNamePart & c) const bool TraditionalLayout::has_package_named(const QualifiedPackageName & q) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When checking for package '" + stringify(q) + "' in '" + stringify(_imp->repository->name()) + ":"); @@ -355,7 +354,7 @@ TraditionalLayout::has_package_named(const QualifiedPackageName & q) const void TraditionalLayout::need_category_names_collection() const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); if (_imp->category_names_collection) return; @@ -371,7 +370,7 @@ TraditionalLayout::need_category_names_collection() const std::shared_ptr<const CategoryNamePartSet> TraditionalLayout::category_names() const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When fetching category names in " + stringify(stringify(_imp->repository->name())) + ":"); @@ -382,7 +381,7 @@ TraditionalLayout::category_names() const std::shared_ptr<const QualifiedPackageNameSet> TraditionalLayout::package_names(const CategoryNamePart & c) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); using namespace std::placeholders; @@ -431,7 +430,7 @@ TraditionalLayout::package_names(const CategoryNamePart & c) const std::shared_ptr<const PackageIDSequence> TraditionalLayout::package_ids(const QualifiedPackageName & n) const { - Lock l(_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->big_nasty_mutex); Context context("When fetching versions of '" + stringify(n) + "' in " + stringify(_imp->repository->name()) + ":"); diff --git a/paludis/repositories/e/traditional_profile.cc b/paludis/repositories/e/traditional_profile.cc index 8d857ce1b..cf34e713f 100644 --- a/paludis/repositories/e/traditional_profile.cc +++ b/paludis/repositories/e/traditional_profile.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -39,7 +39,6 @@ #include <paludis/util/create_iterator-impl.hh> #include <paludis/util/config_file.hh> #include <paludis/util/hashes.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/map.hh> #include <paludis/util/fs_stat.hh> #include <paludis/util/fs_error.hh> @@ -59,6 +58,7 @@ #include <algorithm> #include <set> #include <vector> +#include <mutex> #include <strings.h> @@ -127,7 +127,7 @@ namespace paludis std::shared_ptr<Set<std::string> > iuse_implicit; std::unordered_map<std::string, std::shared_ptr<Set<std::string> > > use_expand_values; KnownMap known_choice_value_names; - mutable Mutex known_choice_value_names_for_separator_mutex; + mutable std::mutex known_choice_value_names_for_separator_mutex; mutable std::unordered_map<char, KnownMap> known_choice_value_names_for_separator; StackedValuesList stacked_values_list; @@ -971,7 +971,7 @@ TraditionalProfile::known_choice_value_names( const std::shared_ptr<const Choice> & choice ) const { - Lock l(_imp->known_choice_value_names_for_separator_mutex); + std::unique_lock<std::mutex> l(_imp->known_choice_value_names_for_separator_mutex); char separator(id->eapi()->supported()->choices_options()->use_expand_separator()); std::unordered_map<char, KnownMap>::iterator it(_imp->known_choice_value_names_for_separator.find(separator)); diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc index 5c828dc31..eb5f44a20 100644 --- a/paludis/repositories/e/vdb_repository.cc +++ b/paludis/repositories/e/vdb_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -57,7 +57,6 @@ #include <paludis/slot.hh> #include <paludis/util/accept_visitor.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/is_file_with_extension.hh> #include <paludis/util/log.hh> #include <paludis/util/set.hh> @@ -92,6 +91,7 @@ #include <list> #include <map> #include <iostream> +#include <mutex> #include <cstring> #include <cerrno> #include <ctime> @@ -110,7 +110,7 @@ namespace paludis { VDBRepositoryParams params; - const std::shared_ptr<Mutex> big_nasty_mutex; + const std::shared_ptr<std::recursive_mutex> big_nasty_mutex; mutable CategoryMap categories; mutable bool has_category_names; @@ -118,7 +118,7 @@ namespace paludis std::shared_ptr<RepositoryNameCache> names_cache; - Imp(const VDBRepository * const, const VDBRepositoryParams &, std::shared_ptr<Mutex> = std::make_shared<Mutex>()); + Imp(const VDBRepository * const, const VDBRepositoryParams &, std::shared_ptr<std::recursive_mutex> = std::make_shared<std::recursive_mutex>()); ~Imp(); std::shared_ptr<const MetadataValueKey<FSPath> > location_key; @@ -130,7 +130,7 @@ namespace paludis }; Imp<VDBRepository>::Imp(const VDBRepository * const r, - const VDBRepositoryParams & p, std::shared_ptr<Mutex> m) : + const VDBRepositoryParams & p, std::shared_ptr<std::recursive_mutex> m) : params(p), big_nasty_mutex(m), has_category_names(false), @@ -192,7 +192,7 @@ VDBRepository::_add_metadata_keys() const bool VDBRepository::has_category_named(const CategoryNamePart & c, const RepositoryContentMayExcludes &) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); Context context("When checking for category '" + stringify(c) + "' in " + stringify(name()) + ":"); @@ -204,7 +204,7 @@ VDBRepository::has_category_named(const CategoryNamePart & c, const RepositoryCo bool VDBRepository::has_package_named(const QualifiedPackageName & q, const RepositoryContentMayExcludes &) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); Context context("When checking for package '" + stringify(q) + "' in " + stringify(name()) + ":"); @@ -229,7 +229,7 @@ VDBRepository::is_unimportant() const std::shared_ptr<const CategoryNamePartSet> VDBRepository::category_names(const RepositoryContentMayExcludes &) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); Context context("When fetching category names in " + stringify(name()) + ":"); @@ -246,7 +246,7 @@ VDBRepository::category_names(const RepositoryContentMayExcludes &) const std::shared_ptr<const QualifiedPackageNameSet> VDBRepository::package_names(const CategoryNamePart & c, const RepositoryContentMayExcludes & x) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); Context context("When fetching package names in category '" + stringify(c) + "' in " + stringify(name()) + ":"); @@ -265,7 +265,7 @@ VDBRepository::package_names(const CategoryNamePart & c, const RepositoryContent std::shared_ptr<const PackageIDSequence> VDBRepository::package_ids(const QualifiedPackageName & n, const RepositoryContentMayExcludes & x) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); Context context("When fetching versions of '" + stringify(n) + "' in " + stringify(name()) + ":"); @@ -567,7 +567,7 @@ VDBRepository::perform_uninstall( void VDBRepository::invalidate() { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); _imp.reset(new Imp<VDBRepository>(this, _imp->params, _imp->big_nasty_mutex)); _add_metadata_keys(); } @@ -575,7 +575,7 @@ VDBRepository::invalidate() void VDBRepository::regenerate_cache() const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); _imp->names_cache->regenerate_cache(); } @@ -583,7 +583,7 @@ VDBRepository::regenerate_cache() const std::shared_ptr<const CategoryNamePartSet> VDBRepository::category_names_containing_package(const PackageNamePart & p, const RepositoryContentMayExcludes & x) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); if (! _imp->names_cache->usable()) return Repository::category_names_containing_package(p, x); @@ -803,7 +803,7 @@ VDBRepository::merge(const MergeParams & m) void VDBRepository::need_category_names() const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); if (_imp->has_category_names) return; @@ -832,7 +832,7 @@ VDBRepository::need_category_names() const void VDBRepository::need_package_ids(const CategoryNamePart & c) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); if (_imp->categories[c]) return; @@ -874,7 +874,7 @@ VDBRepository::need_package_ids(const CategoryNamePart & c) const const std::shared_ptr<const ERepositoryID> VDBRepository::make_id(const QualifiedPackageName & q, const VersionSpec & v, const FSPath & f) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); Context context("When creating ID for '" + stringify(q) + "-" + stringify(v) + "' from '" + stringify(f) + "':"); @@ -885,7 +885,7 @@ VDBRepository::make_id(const QualifiedPackageName & q, const VersionSpec & v, co const std::shared_ptr<const ERepositoryID> VDBRepository::package_id_if_exists(const QualifiedPackageName & q, const VersionSpec & v) const { - Lock l(*_imp->big_nasty_mutex); + std::unique_lock<std::recursive_mutex> lock(*_imp->big_nasty_mutex); if (! has_package_named(q, { })) return std::shared_ptr<const ERepositoryID>(); diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc index 4b2ad7d83..440b3be7a 100644 --- a/paludis/repositories/fake/fake_package_id.cc +++ b/paludis/repositories/fake/fake_package_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -35,7 +35,6 @@ #include <paludis/slot.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/tokeniser.hh> #include <paludis/util/set.hh> @@ -635,7 +634,7 @@ namespace paludis template <> struct Imp<FakePackageID> { - mutable Mutex mutex; + mutable std::recursive_mutex mutex; const Environment * const env; const RepositoryName repository_name; @@ -882,7 +881,7 @@ FakePackageID::arbitrary_less_than_comparison(const PackageID & other) const void FakePackageID::need_keys_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if (! _imp->build_dependencies) { @@ -1007,7 +1006,7 @@ namespace void FakePackageID::need_masks_added() const { - Lock l(_imp->mutex); + std::unique_lock<std::recursive_mutex> lock(_imp->mutex); if (_imp->has_masks) return; diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc index 6cd669724..63535375a 100644 --- a/paludis/repositories/unpackaged/installed_id.cc +++ b/paludis/repositories/unpackaged/installed_id.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -154,7 +154,7 @@ namespace { private: mutable std::shared_ptr<const std::string> _v; - mutable Mutex _mutex; + mutable std::mutex _mutex; const FSPath _f; const std::string _raw_name; @@ -172,7 +172,7 @@ namespace const std::string parse_value() const { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); if (_v) return *_v; @@ -204,7 +204,7 @@ namespace { private: mutable std::shared_ptr<Set<std::string> > _v; - mutable Mutex _mutex; + mutable std::mutex _mutex; FSPathSequence _f; const std::string _raw_name; @@ -226,7 +226,7 @@ namespace const std::shared_ptr<const Set<std::string> > parse_value() const { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); if (_v) return _v; @@ -271,7 +271,7 @@ namespace private: const Environment * const _env; mutable std::shared_ptr<const DependencySpecTree> _v; - mutable Mutex _mutex; + mutable std::mutex _mutex; const FSPath _f; const std::shared_ptr<const DependenciesLabelSequence> _labels; @@ -294,7 +294,7 @@ namespace const std::shared_ptr<const DependencySpecTree> parse_value() const { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); if (_v) return _v; diff --git a/paludis/repositories/unpackaged/installed_repository.cc b/paludis/repositories/unpackaged/installed_repository.cc index 3e572796a..7763261c5 100644 --- a/paludis/repositories/unpackaged/installed_repository.cc +++ b/paludis/repositories/unpackaged/installed_repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -127,7 +127,7 @@ InstalledUnpackagedRepository::package_ids(const QualifiedPackageName & q, const for (IndirectIterator<NDBAMEntrySequence::ConstIterator> e(entries->begin()), e_end(entries->end()) ; e != e_end ; ++e) { - Lock l(*(*e).mutex()); + std::unique_lock<std::mutex> l(*(*e).mutex()); if (! (*e).package_id()) (*e).package_id() = std::make_shared<InstalledUnpackagedID>(_imp->params.environment(), (*e).name(), (*e).version(), (*e).slot(), name(), (*e).fs_location(), (*e).magic(), installed_root_key()->parse_value(), &_imp->ndbam); diff --git a/paludis/repositories/unpackaged/unpackaged_key.cc b/paludis/repositories/unpackaged/unpackaged_key.cc index 67e56dbcc..587f74753 100644 --- a/paludis/repositories/unpackaged/unpackaged_key.cc +++ b/paludis/repositories/unpackaged/unpackaged_key.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -20,7 +20,6 @@ #include <paludis/repositories/unpackaged/unpackaged_key.hh> #include <paludis/repositories/unpackaged/unpackaged_id.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/set.hh> #include <paludis/util/make_named_values.hh> #include <paludis/choice.hh> @@ -28,6 +27,7 @@ #include <paludis/comma_separated_dep_parser.hh> #include <paludis/comma_separated_dep_pretty_printer.hh> #include <memory> +#include <mutex> using namespace paludis; using namespace paludis::unpackaged_repositories; @@ -118,7 +118,7 @@ namespace paludis const Environment * const env; const UnpackagedID * const id; - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::shared_ptr<Choices> value; const std::string raw_name; @@ -150,7 +150,7 @@ UnpackagedChoicesKey::~UnpackagedChoicesKey() const std::shared_ptr<const Choices> UnpackagedChoicesKey::parse_value() const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (! _imp->value) { _imp->value = std::make_shared<Choices>(); diff --git a/paludis/repository_name_cache.cc b/paludis/repository_name_cache.cc index 26ae537eb..87ee32a7a 100644 --- a/paludis/repository_name_cache.cc +++ b/paludis/repository_name_cache.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -23,7 +23,6 @@ #include <paludis/util/stringify.hh> #include <paludis/util/set.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/wrapped_output_iterator.hh> #include <paludis/util/hashes.hh> @@ -35,6 +34,7 @@ #include <unordered_map> #include <memory> #include <set> +#include <mutex> #include <cstring> #include <cerrno> @@ -47,7 +47,7 @@ namespace paludis template<> struct Imp<RepositoryNameCache> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable bool usable; mutable FSPath location; @@ -192,7 +192,7 @@ RepositoryNameCache::~RepositoryNameCache() std::shared_ptr<const CategoryNamePartSet> RepositoryNameCache::category_names_containing_package(const PackageNamePart & p) const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> l(_imp->mutex); if (! usable()) return std::shared_ptr<const CategoryNamePartSet>(); @@ -211,7 +211,7 @@ RepositoryNameCache::category_names_containing_package(const PackageNamePart & p void RepositoryNameCache::regenerate_cache() const { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> l(_imp->mutex); if (_imp->location == FSPath("/var/empty")) return; @@ -277,7 +277,7 @@ RepositoryNameCache::regenerate_cache() const void RepositoryNameCache::add(const QualifiedPackageName & q) { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> l(_imp->mutex); if (! usable()) return; @@ -296,7 +296,7 @@ RepositoryNameCache::add(const QualifiedPackageName & q) void RepositoryNameCache::remove(const QualifiedPackageName & q) { - Lock l(_imp->mutex); + std::unique_lock<std::mutex> l(_imp->mutex); if (! usable()) return; diff --git a/paludis/resolver/get_resolvents_for_helper.cc b/paludis/resolver/get_resolvents_for_helper.cc index 35c782e8c..3f255246b 100644 --- a/paludis/resolver/get_resolvents_for_helper.cc +++ b/paludis/resolver/get_resolvents_for_helper.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2010, 2011 Ciaran McCreesh + * Copyright (c) 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -30,7 +30,6 @@ #include <paludis/util/wrapped_output_iterator.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/enum_iterator.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/hashes.hh> @@ -47,6 +46,7 @@ #include <algorithm> #include <tuple> #include <unordered_map> +#include <mutex> using namespace paludis; using namespace paludis::resolver; @@ -80,7 +80,7 @@ namespace paludis bool want_installed_slots_otherwise; bool fallback_to_other_slots_otherwise; - mutable Mutex cache_mutex; + mutable std::mutex cache_mutex; mutable std::unordered_map< CacheKey, std::pair<std::shared_ptr<const Resolvents>, bool>, @@ -320,7 +320,7 @@ GetResolventsForHelper::operator() ( if (cache_ok) { - Lock lock(_imp->cache_mutex); + std::unique_lock<std::mutex> lock(_imp->cache_mutex); auto c(_imp->cache.find(cache_key)); if (_imp->cache.end() != c) return c->second; @@ -398,7 +398,7 @@ GetResolventsForHelper::operator() ( if (cache_ok) { - Lock lock(_imp->cache_mutex); + std::unique_lock<std::mutex> lock(_imp->cache_mutex); _imp->cache.insert(std::make_pair(cache_key, result)); } diff --git a/paludis/set_file.cc b/paludis/set_file.cc index 646ccf4b8..4c40669e1 100644 --- a/paludis/set_file.cc +++ b/paludis/set_file.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -24,7 +24,6 @@ #include <paludis/util/pimp-impl.hh> #include <paludis/util/sequence.hh> #include <paludis/util/options.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/config_file.hh> #include <paludis/util/system.hh> #include <paludis/util/safe_ofstream.hh> @@ -43,6 +42,7 @@ #include <list> #include <vector> #include <algorithm> +#include <mutex> using namespace paludis; @@ -73,7 +73,7 @@ namespace public SetFileHandler { private: - mutable Mutex _mutex; + mutable std::mutex _mutex; const SetFileParams _p; std::list<std::string> _lines; @@ -110,7 +110,7 @@ namespace public SetFileHandler { private: - mutable Mutex _mutex; + mutable std::mutex _mutex; const SetFileParams _p; std::list<std::string> _lines; @@ -359,7 +359,7 @@ SimpleHandler::_create_contents() const std::shared_ptr<SetSpecTree> SimpleHandler::contents() const { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); if (! _contents) _create_contents(); @@ -370,7 +370,7 @@ SimpleHandler::contents() const bool SimpleHandler::add(const std::string & p) { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); bool result(false); if (_lines.end() == std::find(_lines.begin(), _lines.end(), p)) @@ -387,7 +387,7 @@ SimpleHandler::add(const std::string & p) bool SimpleHandler::remove(const std::string & p) { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); Context context("When removing '" + stringify(p) + "' from simple set file '" + stringify(_p.file_name()) + "':"); @@ -410,7 +410,7 @@ SimpleHandler::remove(const std::string & p) void SimpleHandler::rewrite() const { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); Context context("When rewriting simple set file '" + stringify(_p.file_name()) + "':"); @@ -454,7 +454,7 @@ PaludisConfHandler::_create_contents() const std::shared_ptr<SetSpecTree> PaludisConfHandler::contents() const { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); if (! _contents) _create_contents(); @@ -465,7 +465,7 @@ PaludisConfHandler::contents() const bool PaludisConfHandler::add(const std::string & p) { - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); bool result(false); if (_lines.end() == std::find_if(_lines.begin(), _lines.end(), TokenOneIs(p))) @@ -483,7 +483,7 @@ PaludisConfHandler::remove(const std::string & p) { Context context("When removing '" + stringify(p) + "' from paludis conf set file '" + stringify(_p.file_name()) + "':"); - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); _contents.reset(); bool result(false); @@ -505,7 +505,7 @@ PaludisConfHandler::rewrite() const { Context context("When rewriting paludis conf set file '" + stringify(_p.file_name()) + "':"); - Lock l(_mutex); + std::unique_lock<std::mutex> l(_mutex); try { diff --git a/paludis/util/active_object_ptr.hh b/paludis/util/active_object_ptr.hh index 8059f3b16..69527ac84 100644 --- a/paludis/util/active_object_ptr.hh +++ b/paludis/util/active_object_ptr.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -21,8 +21,8 @@ #define PALUDIS_GUARD_PALUDIS_UTIL_ACTIVE_OBJECT_PTR_HH 1 #include <paludis/util/active_object_ptr-fwd.hh> -#include <paludis/util/mutex.hh> #include <memory> +#include <mutex> namespace paludis { @@ -31,18 +31,18 @@ namespace paludis { private: T_ _ptr; - std::shared_ptr<Mutex> _mutex; + std::shared_ptr<std::mutex> _mutex; class Deref { private: const ActiveObjectPtr * _ptr; - std::shared_ptr<Lock> _lock; + std::unique_lock<std::mutex> _lock; public: Deref(const ActiveObjectPtr * p) : _ptr(p), - _lock(std::make_shared<Lock>(*p->_mutex)) + _lock(*p->_mutex) { } @@ -57,7 +57,7 @@ namespace paludis public: ActiveObjectPtr(const T_ & t) : _ptr(t), - _mutex(std::make_shared<Mutex>()) + _mutex(std::make_shared<std::mutex>()) { } diff --git a/paludis/util/buffer_output_stream.cc b/paludis/util/buffer_output_stream.cc index 6e474f9ba..9c321c9e9 100644 --- a/paludis/util/buffer_output_stream.cc +++ b/paludis/util/buffer_output_stream.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -19,10 +19,9 @@ #include <paludis/util/buffer_output_stream.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/condition_variable.hh> #include <list> #include <string> +#include <mutex> using namespace paludis; @@ -31,7 +30,7 @@ namespace paludis template <> struct Imp<BufferOutputStreamBuf> { - mutable Mutex mutex; + mutable std::mutex mutex; std::list<std::string> complete_strings; std::string active_string; @@ -55,7 +54,7 @@ BufferOutputStreamBuf::~BufferOutputStreamBuf() BufferOutputStreamBuf::int_type BufferOutputStreamBuf::overflow(int_type c) { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (c != traits_type::eof()) { @@ -73,7 +72,7 @@ BufferOutputStreamBuf::overflow(int_type c) std::streamsize BufferOutputStreamBuf::xsputn(const char * s, std::streamsize num) { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->active_string.append(std::string(s, num)); if (std::string::npos != _imp->active_string.find_first_of("\r\n", _imp->active_string.length() - num)) @@ -91,7 +90,7 @@ BufferOutputStreamBuf::unbuffer(std::ostream & stream) std::list<std::string> c; { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->complete_strings.swap(c); } @@ -105,7 +104,7 @@ BufferOutputStreamBuf::unbuffer(std::ostream & stream) bool BufferOutputStreamBuf::anything_to_unbuffer() const { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); return ! _imp->complete_strings.empty(); } diff --git a/paludis/util/condition_variable.cc b/paludis/util/condition_variable.cc deleted file mode 100644 index f65930957..000000000 --- a/paludis/util/condition_variable.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2010 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <paludis/util/condition_variable.hh> -#include <paludis/util/exception.hh> -#include <paludis/util/stringify.hh> -#include <paludis/util/log.hh> -#include <sys/time.h> -#include <time.h> -#include <errno.h> -#include <cstring> - -using namespace paludis; - -ConditionVariable::ConditionVariable() : - _cond(new pthread_cond_t) -{ - pthread_cond_init(_cond, 0); -} - -ConditionVariable::~ConditionVariable() -{ - pthread_cond_destroy(_cond); - delete _cond; -} - -void -ConditionVariable::broadcast() -{ - pthread_cond_broadcast(_cond); -} - -void -ConditionVariable::signal() -{ - pthread_cond_signal(_cond); -} - -void -ConditionVariable::acquire_then_signal(Mutex & m) -{ - Lock l(m); - signal(); -} - -void -ConditionVariable::wait(Mutex & m) -{ - pthread_cond_wait(_cond, m.posix_mutex()); -} - -bool -ConditionVariable::timed_wait(Mutex & m, const unsigned n, const unsigned ms) -{ - struct timespec t; - clock_gettime(CLOCK_REALTIME, &t); - - t.tv_sec += n; - t.tv_nsec += (1000000 * ms); - - if (t.tv_nsec >= 1000000000) - { - t.tv_nsec -= 1000000000; - t.tv_sec += 1; - } - - int r(pthread_cond_timedwait(_cond, m.posix_mutex(), &t)); - - if (0 == r) - return true; - else - { - if (ETIMEDOUT != r) - Log::get_instance()->message("condition_variable.timed_wait_failed", ll_warning, lc_context) - << "pthread_cond_timedwait returned " << std::strerror(r) << ", something icky happened"; - return false; - } -} - diff --git a/paludis/util/condition_variable.hh b/paludis/util/condition_variable.hh deleted file mode 100644 index 4b6197afb..000000000 --- a/paludis/util/condition_variable.hh +++ /dev/null @@ -1,95 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2010 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_UTIL_CONDITION_VARIABLE_HH -#define PALUDIS_GUARD_PALUDIS_UTIL_CONDITION_VARIABLE_HH 1 - -#include <paludis/util/attributes.hh> -#include <paludis/util/mutex.hh> -#include <pthread.h> - -/** \file - * Declarations for the ConditionVariable class. - * - * \ingroup g_threads - * - * \section Examples - * - * - None at this time. - */ - -namespace paludis -{ - /** - * A basic condition variable. - * - * If threading is disabled, waiting and signalling are no-ops. - * - * \ingroup g_threads - * \since 0.26 - * \nosubgrouping - */ - class PALUDIS_VISIBLE ConditionVariable - { - private: - ConditionVariable(const ConditionVariable &); - ConditionVariable & operator= (const ConditionVariable &); - - pthread_cond_t * const _cond; - - public: - ///\name Basic operations - ///\{ - - ConditionVariable(); - ~ConditionVariable(); - - ///\} - - /** - * Broadcast to all waiting threads. - */ - void broadcast(); - - /** - * Signal one waiting thread. - */ - void signal(); - - /** - * Acquire the specified Mutex, then signal. - */ - void acquire_then_signal(Mutex &); - - /** - * Wait, using the specified Mutex for synchronisation. - */ - void wait(Mutex &); - - /** - * Wait, using the specified Mutex for synchronisation, - * but return false if more than n seconds m ms elapse. - * - * \since 0.49 for ms argument - */ - bool timed_wait(Mutex &, const unsigned n, const unsigned m = 0); - }; -} - -#endif diff --git a/paludis/util/condition_variable_TEST.cc b/paludis/util/condition_variable_TEST.cc deleted file mode 100644 index 1cb20530a..000000000 --- a/paludis/util/condition_variable_TEST.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2011 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <paludis/util/condition_variable.hh> - -#include <gtest/gtest.h> - -using namespace paludis; - -TEST(ConditionVariable, Signal) -{ - ConditionVariable c; - c.signal(); - c.broadcast(); - SUCCEED(); -} - diff --git a/paludis/util/executor.cc b/paludis/util/executor.cc index 2b4836a92..b6338a2ea 100644 --- a/paludis/util/executor.cc +++ b/paludis/util/executor.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -19,13 +19,13 @@ #include <paludis/util/executor.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/condition_variable.hh> #include <paludis/util/exception.hh> #include <paludis/util/stringify.hh> #include <map> #include <list> #include <thread> +#include <mutex> +#include <condition_variable> using namespace paludis; @@ -49,8 +49,8 @@ namespace paludis Queues queues; ReadyForPost ready_for_post; - Mutex mutex; - ConditionVariable condition; + std::mutex mutex; + std::condition_variable condition; Imp(int u) : ms_update_interval(u), @@ -76,9 +76,9 @@ Executor::_one(const std::shared_ptr<Executive> executive) { executive->execute_threaded(); - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->ready_for_post.push_back(executive); - _imp->condition.signal(); + _imp->condition.notify_all(); } @@ -113,7 +113,7 @@ Executor::execute() typedef std::map<std::string, std::pair<std::thread, std::shared_ptr<Executive> > > Running; Running running; - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); while (true) { bool any(false); @@ -145,7 +145,7 @@ Executor::execute() break; } - _imp->condition.timed_wait(_imp->mutex, _imp->ms_update_interval / 1000, _imp->ms_update_interval % 1000); + _imp->condition.wait_for(lock, std::chrono::milliseconds(_imp->ms_update_interval)); for (Running::iterator r(running.begin()), r_end(running.end()) ; r != r_end ; ++r) @@ -166,7 +166,7 @@ Executor::execute() } } -Mutex & +std::mutex & Executor::exclusivity_mutex() { return _imp->mutex; diff --git a/paludis/util/executor.hh b/paludis/util/executor.hh index 9f33cd142..695b54459 100644 --- a/paludis/util/executor.hh +++ b/paludis/util/executor.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -23,9 +23,9 @@ #include <paludis/util/executor-fwd.hh> #include <paludis/util/pimp.hh> #include <paludis/util/attributes.hh> -#include <paludis/util/mutex-fwd.hh> -#include <string> #include <memory> +#include <mutex> +#include <string> namespace paludis { @@ -63,7 +63,7 @@ namespace paludis void execute(); - Mutex & exclusivity_mutex() PALUDIS_ATTRIBUTE((warn_unused_result)); + std::mutex & exclusivity_mutex() PALUDIS_ATTRIBUTE((warn_unused_result)); }; extern template class Pimp<Executor>; diff --git a/paludis/util/files.m4 b/paludis/util/files.m4 index 912fa7ebc..7636efab7 100644 --- a/paludis/util/files.m4 +++ b/paludis/util/files.m4 @@ -17,7 +17,6 @@ add(`channel', `hh', `cc') add(`checked_delete', `hh') add(`clone', `hh', `impl') add(`config_file', `hh', `cc', `fwd', `se', `gtest', `testscript') -add(`condition_variable', `hh', `cc', `gtest') add(`cookie', `hh', `cc') add(`create_iterator', `hh', `fwd', `impl', `gtest') add(`damerau_levenshtein', `hh', `cc', `gtest') @@ -54,7 +53,6 @@ add(`make_shared_copy', `hh', `fwd') add(`map', `hh', `fwd', `impl', `cc') add(`member_iterator', `hh', `fwd', `impl', `gtest') add(`md5', `hh', `cc', `gtest') -add(`mutex', `hh', `cc', `fwd', `gtest') add(`named_value', `hh', `cc', `fwd') add(`no_type', `hh') add(`operators', `hh') diff --git a/paludis/util/log.cc b/paludis/util/log.cc index 507bf6cd4..1a0b764c2 100644 --- a/paludis/util/log.cc +++ b/paludis/util/log.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2010, 2011, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -17,13 +17,14 @@ * Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <iostream> -#include <exception> #include <paludis/util/log.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/singleton-impl.hh> #include <paludis/util/exception.hh> -#include <paludis/util/mutex.hh> +#include <iostream> +#include <exception> +#include <mutex> + #include "config.h" #ifdef __linux__ @@ -42,7 +43,7 @@ namespace paludis template<> struct Imp<Log> { - Mutex mutex; + std::mutex mutex; LogLevel log_level; std::ostream * stream; std::string program_name; @@ -134,7 +135,7 @@ Log::~Log() void Log::set_log_level(const LogLevel l) { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->log_level = l; } @@ -147,7 +148,7 @@ Log::log_level() const void Log::_message(const std::string & id, const LogLevel l, const LogContext c, const std::string & s) { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (lc_context == c) _imp->message(id, l, c, @@ -178,14 +179,14 @@ Log::message(const std::string & id, const LogLevel l, const LogContext c) void Log::set_log_stream(std::ostream * const s) { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->stream = s; } void Log::set_program_name(const std::string & s) { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->program_name = s; } diff --git a/paludis/util/mutex-fwd.hh b/paludis/util/mutex-fwd.hh deleted file mode 100644 index ca9c22a71..000000000 --- a/paludis/util/mutex-fwd.hh +++ /dev/null @@ -1,30 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2008 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_FWD_HH -#define PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_FWD_HH 1 - -namespace paludis -{ - class Mutex; - class Lock; - class TryLock; -} - -#endif diff --git a/paludis/util/mutex.cc b/paludis/util/mutex.cc deleted file mode 100644 index 9080c038a..000000000 --- a/paludis/util/mutex.cc +++ /dev/null @@ -1,103 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <paludis/util/mutex.hh> -#include <paludis/util/exception.hh> -#include <paludis/util/stringify.hh> -#include <cstring> - -using namespace paludis; - -namespace -{ - pthread_mutexattr_t make_recursive_attr() - { - pthread_mutexattr_t result; - pthread_mutexattr_init(&result); - pthread_mutexattr_settype(&result, PTHREAD_MUTEX_RECURSIVE); - return result; - } -} - -Mutex::Mutex() -{ - static const pthread_mutexattr_t attr = make_recursive_attr(); - pthread_mutex_init(&_mutex, &attr); -} - -Mutex::~Mutex() -{ - int r(0); - if (0 != ((r = pthread_mutex_destroy(&_mutex)))) - throw InternalError(PALUDIS_HERE, "mutex destory failed: " + stringify(strerror(r))); -} - -pthread_mutex_t * -Mutex::posix_mutex() -{ - return &_mutex; -} - -Lock::Lock(Mutex & m) : - _mutex(&m) -{ - int r(0); - if (0 != ((r = pthread_mutex_lock(_mutex->posix_mutex())))) - throw InternalError(PALUDIS_HERE, "mutex lock failed: " + stringify(strerror(r))); -} - -Lock::~Lock() -{ - int r(0); - if (0 != ((r = pthread_mutex_unlock(_mutex->posix_mutex())))) - throw InternalError(PALUDIS_HERE, "mutex unlock failed: " + stringify(strerror(r))); -} - -void -Lock::acquire_then_release_old(Mutex & m) -{ - int r(0); - if (0 != ((r = pthread_mutex_lock(m.posix_mutex())))) - throw InternalError(PALUDIS_HERE, "mutex lock failed: " + stringify(strerror(r))); - if (0 != ((r = pthread_mutex_unlock(_mutex->posix_mutex())))) - throw InternalError(PALUDIS_HERE, "mutex unlock failed: " + stringify(strerror(r))); - _mutex = &m; -} - -TryLock::TryLock(Mutex & m) : - _mutex(&m) -{ - if (0 != pthread_mutex_trylock(_mutex->posix_mutex())) - _mutex = 0; -} - -TryLock::~TryLock() -{ - int r(0); - if (_mutex) - if (0 != ((r = pthread_mutex_unlock(_mutex->posix_mutex())))) - throw InternalError(PALUDIS_HERE, "mutex unlock failed: " + stringify(strerror(r))); -} - -bool -TryLock::operator() () const -{ - return _mutex; -} - diff --git a/paludis/util/mutex.hh b/paludis/util/mutex.hh deleted file mode 100644 index 5c733850d..000000000 --- a/paludis/util/mutex.hh +++ /dev/null @@ -1,133 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_HH -#define PALUDIS_GUARD_PALUDIS_UTIL_MUTEX_HH 1 - -#include <paludis/util/mutex-fwd.hh> -#include <paludis/util/attributes.hh> -#include <pthread.h> - -/** - * Declarations for Mutex, Lock and TryLock. - * - * \ingroup g_threads - * - * \section Examples - * - * - None at this time. - */ - -namespace paludis -{ - /** - * A simple mutex class, which can be locked using Lock and TryLock. - * - * \ingroup g_threads - * \since 0.26 - */ - class PALUDIS_VISIBLE Mutex - { - private: - Mutex(const Mutex &); - Mutex & operator= (const Mutex &); - - pthread_mutex_t _mutex; - - public: - ///\name Basic operations - ///\{ - - explicit Mutex(); - ~Mutex(); - - ///\} - - pthread_mutex_t * posix_mutex() PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - - /** - * A RAII lock for a Mutex. - * - * If threading is disabled, locking is a no-op. - * - * \ingroup g_threads - * \nosubgrouping - * \since 0.26 - */ - class PALUDIS_VISIBLE Lock - { - private: - Lock(const Lock &); - Lock & operator= (const Lock &); - - Mutex * _mutex; - - public: - ///\name Basic operations - ///\{ - - explicit Lock(Mutex &); - ~Lock(); - - ///\} - - /** - * Acquire a lock on the provided Mutex, and then release our - * previously owned lock. - * - * Use with caution -- this is a good way of creating deadlocks. - */ - void acquire_then_release_old(Mutex &); - }; - - /** - * A RAII trylock for a Mutex. - * - * If threading is disabled, locking is a no-op and the try always succeeds. - * - * \ingroup g_threads - * \since 0.26 - * \nosubgrouping - */ - class PALUDIS_VISIBLE TryLock - { - private: - TryLock(const TryLock &); - TryLock & operator= (const TryLock &); - - Mutex * _mutex; - - public: - ///\name Basic operations - ///\{ - - explicit TryLock(Mutex &); - ~TryLock(); - - ///\} - - /** - * Did the lock succeed? - */ - bool operator() () const PALUDIS_ATTRIBUTE((warn_unused_result)); - }; -} - -#endif diff --git a/paludis/util/mutex_TEST.cc b/paludis/util/mutex_TEST.cc deleted file mode 100644 index 1131ef317..000000000 --- a/paludis/util/mutex_TEST.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* vim: set sw=4 sts=4 et foldmethod=syntax : */ - -/* - * Copyright (c) 2007, 2011 Ciaran McCreesh - * - * This file is part of the Paludis package manager. Paludis is free software; - * you can redistribute it and/or modify it under the terms of the GNU General - * Public License version 2, as published by the Free Software Foundation. - * - * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <paludis/util/mutex.hh> - -#include <gtest/gtest.h> - -using namespace paludis; - -TEST(Mutex, Lock) -{ - Mutex m; - Lock l(m); - SUCCEED(); -} - diff --git a/paludis/util/pool-impl.hh b/paludis/util/pool-impl.hh index 3fdd12b8b..0f80f1e06 100644 --- a/paludis/util/pool-impl.hh +++ b/paludis/util/pool-impl.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2011 Ciaran McCreesh + * Copyright (c) 2011, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -21,11 +21,11 @@ #define PALUDIS_GUARD_PALUDIS_UTIL_POOL_IMPL_HH 1 #include <paludis/util/pool.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/hashes.hh> #include <paludis/util/stringify.hh> #include <unordered_map> #include <memory> +#include <mutex> namespace paludis { @@ -49,7 +49,7 @@ namespace paludis template <typename T_> struct Imp<Pool<T_> > { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::unordered_map<PoolKeys, std::shared_ptr<const T_>, PoolKeysHasher, PoolKeysComparator> store; mutable unsigned reused; @@ -94,7 +94,7 @@ namespace paludis PoolKeys keys; keys.add(args...); - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); auto i(_imp->store.find(keys)); if (i == _imp->store.end()) { diff --git a/paludis/util/pool.cc b/paludis/util/pool.cc index f73673ece..215629943 100644 --- a/paludis/util/pool.cc +++ b/paludis/util/pool.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2011 Ciaran McCreesh + * Copyright (c) 2011, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -19,7 +19,6 @@ #include <paludis/util/pool-impl.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <list> #include <memory> @@ -113,10 +112,10 @@ PoolKeysComparator::operator() (const PoolKeys & a, const PoolKeys & b) const int PoolKeyTypeCodes::next() { - static Mutex mutex; + static std::mutex mutex; static int result(0); - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); return ++result; } diff --git a/paludis/util/singleton-impl.hh b/paludis/util/singleton-impl.hh index 75875dfb4..dda1a1c2d 100644 --- a/paludis/util/singleton-impl.hh +++ b/paludis/util/singleton-impl.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2010 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2010, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -24,7 +24,7 @@ #include <paludis/util/exception.hh> #include <paludis/util/save.hh> #include <paludis/util/stringify.hh> -#include <paludis/util/mutex.hh> +#include <mutex> template <typename OurType_> void @@ -66,8 +66,8 @@ template<typename OurType_> OurType_ * paludis::Singleton<OurType_>::get_instance() { - static Mutex m; - Lock l(m); + static std::recursive_mutex m; + std::unique_lock<std::recursive_mutex> lock(m); OurType_ * * i(_get_instance_ptr()); diff --git a/paludis/util/singleton_TEST.cc b/paludis/util/singleton_TEST.cc index 9f856f4a2..d6bea144c 100644 --- a/paludis/util/singleton_TEST.cc +++ b/paludis/util/singleton_TEST.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -19,7 +19,6 @@ #include <paludis/util/singleton.hh> #include <paludis/util/singleton-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/thread_pool.hh> #include <functional> @@ -99,19 +98,19 @@ namespace private: MyThreadedClass() { - Lock l(mutex); + std::unique_lock<std::mutex> lock(mutex); ++instances; } public: std::string s; - static Mutex mutex; + static std::mutex mutex; static int instances; }; int MyThreadedClass::instances = 0; - Mutex MyThreadedClass::mutex; + std::mutex MyThreadedClass::mutex; static void thread_func(void * * const p) throw () { diff --git a/paludis/util/string_list_stream.cc b/paludis/util/string_list_stream.cc index d665ea2b1..baa33008e 100644 --- a/paludis/util/string_list_stream.cc +++ b/paludis/util/string_list_stream.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -19,10 +19,10 @@ #include <paludis/util/string_list_stream.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/condition_variable.hh> #include <list> #include <string> +#include <mutex> +#include <condition_variable> using namespace paludis; @@ -31,8 +31,8 @@ namespace paludis template <> struct Imp<StringListStreamBuf> { - Mutex mutex; - ConditionVariable condition; + std::mutex mutex; + std::condition_variable condition; std::string active_string; std::list<std::string> future_strings; @@ -59,8 +59,8 @@ StringListStreamBuf::~StringListStreamBuf() StringListStreamBuf::int_type StringListStreamBuf::overflow(int_type c) { - Lock lock(_imp->mutex); - _imp->condition.signal(); + std::unique_lock<std::mutex> lock(_imp->mutex); + _imp->condition.notify_all(); if (c != traits_type::eof()) { @@ -76,8 +76,8 @@ StringListStreamBuf::overflow(int_type c) std::streamsize StringListStreamBuf::xsputn(const char * s, std::streamsize num) { - Lock lock(_imp->mutex); - _imp->condition.signal(); + std::unique_lock<std::mutex> lock(_imp->mutex); + _imp->condition.notify_all(); if ((_imp->future_strings.empty()) || (_imp->future_strings.back().length() + num > 1024)) _imp->future_strings.push_back(std::string(s, num)); @@ -89,15 +89,15 @@ StringListStreamBuf::xsputn(const char * s, std::streamsize num) void StringListStreamBuf::nothing_more_to_write() { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->nothing_more_to_write = true; - _imp->condition.signal(); + _imp->condition.notify_all(); } StringListStreamBuf::int_type StringListStreamBuf::underflow() { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (gptr() < egptr()) return traits_type::to_int_type(*gptr()); @@ -107,7 +107,7 @@ StringListStreamBuf::underflow() if (_imp->nothing_more_to_write) return traits_type::eof(); - _imp->condition.wait(_imp->mutex); + _imp->condition.wait(lock); } _imp->active_string = *_imp->future_strings.begin(); diff --git a/paludis/util/tail_output_stream.cc b/paludis/util/tail_output_stream.cc index 21c933cc4..b51c04a2f 100644 --- a/paludis/util/tail_output_stream.cc +++ b/paludis/util/tail_output_stream.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2008, 2010, 2011, 2012 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -18,12 +18,12 @@ */ #include <paludis/util/tail_output_stream.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/iterator_funcs.hh> #include <functional> #include <algorithm> #include <list> +#include <mutex> using namespace paludis; @@ -36,7 +36,7 @@ namespace paludis const unsigned int size; std::list<std::string> tail; - Mutex mutex; + std::mutex mutex; Imp(const unsigned int nn) : n(1), @@ -74,7 +74,7 @@ TailOutputStreamBuf::xsputn(const char * s, std::streamsize num) void TailOutputStreamBuf::_append(const std::string & s) { - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); for (std::string::size_type p(0), p_end(s.length()) ; p != p_end ; ++p) { if ('\n' == s[p]) @@ -95,7 +95,7 @@ const std::shared_ptr<const Sequence<std::string> > TailOutputStreamBuf::tail(const bool clear) { std::shared_ptr<Sequence<std::string> > result(std::make_shared<Sequence<std::string>>()); - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); for (std::list<std::string>::const_iterator i(_imp->tail.begin()), i_end(_imp->tail.end()), i_last(previous(_imp->tail.end())) ; i != i_end ; ++i) { diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc index 948fa3666..12a001f77 100644 --- a/paludis/version_spec.cc +++ b/paludis/version_spec.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -24,7 +24,6 @@ #include <paludis/util/strip.hh> #include <paludis/util/log.hh> #include <paludis/util/pimp-impl.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/simple_parser.hh> #include <paludis/util/named_value.hh> diff --git a/python/environment.cc b/python/environment.cc index 32a2794c8..fa7bd58d5 100644 --- a/python/environment.cc +++ b/python/environment.cc @@ -55,7 +55,7 @@ class EnvironmentImplementationWrapper : virtual void populate_sets() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("populate_sets")) f(); @@ -66,7 +66,7 @@ class EnvironmentImplementationWrapper : virtual bool accept_license(const std::string & s, const std::shared_ptr<const PackageID> & p) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("accept_license")) return f(s, p); @@ -77,7 +77,7 @@ class EnvironmentImplementationWrapper : virtual bool accept_keywords(const std::shared_ptr<const KeywordNameSet> & k, const std::shared_ptr<const PackageID> & p) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("accept_keywords")) return f(k, p); @@ -88,7 +88,7 @@ class EnvironmentImplementationWrapper : virtual const std::shared_ptr<const Mask> mask_for_breakage(const std::shared_ptr<const PackageID> & p) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("mask_for_breakage")) return f(p); @@ -99,7 +99,7 @@ class EnvironmentImplementationWrapper : virtual const std::shared_ptr<const Mask> mask_for_user(const std::shared_ptr<const PackageID> & p, const bool b) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("mask_for_user")) return f(p, b); @@ -110,7 +110,7 @@ class EnvironmentImplementationWrapper : virtual bool unmasked_by_user(const std::shared_ptr<const PackageID> & p, const std::string & s) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("unmasked_by_user")) return f(p, s); @@ -121,7 +121,7 @@ class EnvironmentImplementationWrapper : virtual std::shared_ptr<const FSPathSequence> bashrc_files() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("bashrc_files")) return f(); @@ -137,7 +137,7 @@ class EnvironmentImplementationWrapper : virtual std::shared_ptr<const FSPathSequence> syncers_dirs() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("syncers_dirs")) return f(); @@ -153,7 +153,7 @@ class EnvironmentImplementationWrapper : virtual std::shared_ptr<const FSPathSequence> fetchers_dirs() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("fetchers_dirs")) return f(); @@ -169,7 +169,7 @@ class EnvironmentImplementationWrapper : virtual std::shared_ptr<const FSPathSequence> hook_dirs() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("hook_dirs")) return f(); @@ -179,7 +179,7 @@ class EnvironmentImplementationWrapper : virtual uid_t reduced_uid() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("reduced_uid")) return f(); @@ -189,7 +189,7 @@ class EnvironmentImplementationWrapper : virtual gid_t reduced_gid() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("reduced_gid")) return f(); @@ -201,7 +201,7 @@ class EnvironmentImplementationWrapper : virtual std::shared_ptr<const MirrorsSequence> mirrors(const std::string & s) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("mirrors")) return f(s); @@ -212,7 +212,7 @@ class EnvironmentImplementationWrapper : virtual std::shared_ptr<const SetNameSet> set_names() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("set_names")) return f(); @@ -228,7 +228,7 @@ class EnvironmentImplementationWrapper : virtual const std::shared_ptr<const SetSpecTree> set(const SetName & s) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("set")) return f(boost::cref(s)); @@ -251,7 +251,7 @@ class EnvironmentImplementationWrapper : virtual std::string distribution() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("distribution")) return f(); @@ -266,7 +266,7 @@ class EnvironmentImplementationWrapper : virtual bool add_to_world(const QualifiedPackageName & s) const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("add_to_world")) return f(s); else @@ -275,7 +275,7 @@ class EnvironmentImplementationWrapper : virtual bool add_to_world(const SetName & s) const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("add_to_world")) return f(s); else @@ -284,7 +284,7 @@ class EnvironmentImplementationWrapper : virtual bool remove_from_world(const QualifiedPackageName & s) const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("remove_from_world")) return f(s); else @@ -293,7 +293,7 @@ class EnvironmentImplementationWrapper : virtual bool remove_from_world(const SetName & s) const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("remove_from_world")) return f(s); else @@ -303,7 +303,7 @@ class EnvironmentImplementationWrapper : virtual std::shared_ptr<PackageIDSequence> operator[] (const Selection & fg) const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("__getitem__")) return f(fg); @@ -318,7 +318,7 @@ class EnvironmentImplementationWrapper : virtual void need_keys_added() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("need_keys_added")) f(); @@ -328,7 +328,7 @@ class EnvironmentImplementationWrapper : virtual const std::shared_ptr<const MetadataValueKey<std::string> > format_key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("format_key")) return f(); @@ -338,7 +338,7 @@ class EnvironmentImplementationWrapper : virtual const std::shared_ptr<const MetadataValueKey<FSPath> > config_location_key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("config_location_key")) return f(); @@ -348,7 +348,7 @@ class EnvironmentImplementationWrapper : virtual const std::shared_ptr<const MetadataValueKey<FSPath> > preferred_root_key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("preferred_root_key")) return f(); @@ -358,7 +358,7 @@ class EnvironmentImplementationWrapper : virtual const std::shared_ptr<const MetadataValueKey<FSPath> > system_root_key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("system_root_key")) return f(); diff --git a/python/mask.cc b/python/mask.cc index c6ef7b66e..4a3fea6ed 100644 --- a/python/mask.cc +++ b/python/mask.cc @@ -84,7 +84,7 @@ struct MaskWrapper : { virtual char key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("key")) return f(); @@ -94,7 +94,7 @@ struct MaskWrapper : virtual const std::string description() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("description")) return f(); @@ -109,7 +109,7 @@ struct UserMaskWrapper : { virtual char key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("key")) return f(); @@ -119,7 +119,7 @@ struct UserMaskWrapper : virtual const std::string description() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("description")) return f(); @@ -134,7 +134,7 @@ struct UnacceptedMaskWrapper : { virtual const std::string unaccepted_key_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("unaccepted_key_name")) return f(); @@ -144,7 +144,7 @@ struct UnacceptedMaskWrapper : virtual char key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("key")) return f(); @@ -154,7 +154,7 @@ struct UnacceptedMaskWrapper : virtual const std::string description() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("description")) return f(); @@ -169,7 +169,7 @@ struct RepositoryMaskWrapper : { virtual const std::string mask_key_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("mask_key_name")) return f(); @@ -179,7 +179,7 @@ struct RepositoryMaskWrapper : virtual char key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("key")) return f(); @@ -189,7 +189,7 @@ struct RepositoryMaskWrapper : virtual const std::string description() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("description")) return f(); @@ -199,7 +199,7 @@ struct RepositoryMaskWrapper : virtual const std::string comment() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("comment")) return f(); @@ -209,7 +209,7 @@ struct RepositoryMaskWrapper : virtual const std::string token() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("token")) return f(); @@ -219,7 +219,7 @@ struct RepositoryMaskWrapper : virtual const FSPath mask_file() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("mask_file")) return f(); @@ -234,7 +234,7 @@ struct UnsupportedMaskWrapper : { virtual const std::string explanation() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("explanation")) return f(); @@ -244,7 +244,7 @@ struct UnsupportedMaskWrapper : virtual char key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("key")) return f(); @@ -254,7 +254,7 @@ struct UnsupportedMaskWrapper : virtual const std::string description() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("description")) return f(); diff --git a/python/metadata_key.cc b/python/metadata_key.cc index f2f9b8561..a5f0a6a3a 100644 --- a/python/metadata_key.cc +++ b/python/metadata_key.cc @@ -182,7 +182,7 @@ struct MetadataPackageIDKeyWrapper : virtual const std::shared_ptr<const PackageID> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("parse_value")) return f(); @@ -192,7 +192,7 @@ struct MetadataPackageIDKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -202,7 +202,7 @@ struct MetadataPackageIDKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -212,7 +212,7 @@ struct MetadataPackageIDKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -235,7 +235,7 @@ struct MetadataStringKeyWrapper : virtual const std::string parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("parse_value")) return f(); @@ -245,7 +245,7 @@ struct MetadataStringKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -255,7 +255,7 @@ struct MetadataStringKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -265,7 +265,7 @@ struct MetadataStringKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -281,7 +281,7 @@ struct MetadataSlotNameKeyWrapper : virtual const Slot parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("parse_value")) return f(); @@ -291,7 +291,7 @@ struct MetadataSlotNameKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -301,7 +301,7 @@ struct MetadataSlotNameKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -311,7 +311,7 @@ struct MetadataSlotNameKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -336,7 +336,7 @@ struct MetadataSectionKeyWrapper : virtual void need_keys_added() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("need_keys_added")) f(); @@ -346,7 +346,7 @@ struct MetadataSectionKeyWrapper : virtual const std::shared_ptr<const MetadataValueKey<std::string> > title_key() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("title_key")) return f(); @@ -356,7 +356,7 @@ struct MetadataSectionKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -366,7 +366,7 @@ struct MetadataSectionKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -376,7 +376,7 @@ struct MetadataSectionKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -392,7 +392,7 @@ struct MetadataTimeKeyWrapper : virtual Timestamp parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("parse_value")) return Timestamp(f(), 0); @@ -402,7 +402,7 @@ struct MetadataTimeKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -412,7 +412,7 @@ struct MetadataTimeKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -422,7 +422,7 @@ struct MetadataTimeKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -438,7 +438,7 @@ struct MetadataChoicesKeyWrapper : virtual const std::shared_ptr<const Choices> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("parse_value")) return f(); @@ -448,7 +448,7 @@ struct MetadataChoicesKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -458,7 +458,7 @@ struct MetadataChoicesKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -468,7 +468,7 @@ struct MetadataChoicesKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -484,7 +484,7 @@ struct MetadataFSPathKeyWrapper : virtual const FSPath parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("parse_value")) return f(); @@ -494,7 +494,7 @@ struct MetadataFSPathKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -504,7 +504,7 @@ struct MetadataFSPathKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -514,7 +514,7 @@ struct MetadataFSPathKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -531,7 +531,7 @@ struct MetadataCollectionKeyWrapper : virtual const std::shared_ptr<const C_> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("parse_value")) return f(); @@ -541,7 +541,7 @@ struct MetadataCollectionKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("raw_name")) return f(); @@ -551,7 +551,7 @@ struct MetadataCollectionKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("human_name")) return f(); @@ -561,7 +561,7 @@ struct MetadataCollectionKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("type")) return f(); @@ -585,7 +585,7 @@ struct MetadataSpecTreeKeyWrapper : virtual const std::shared_ptr<const C_> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("parse_value")) return f(); @@ -595,7 +595,7 @@ struct MetadataSpecTreeKeyWrapper : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("raw_name")) return f(); @@ -605,7 +605,7 @@ struct MetadataSpecTreeKeyWrapper : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("human_name")) return f(); @@ -615,7 +615,7 @@ struct MetadataSpecTreeKeyWrapper : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("type")) return f(); @@ -639,7 +639,7 @@ struct MetadataSpecTreeKeyWrapper<FetchableURISpecTree> : virtual const std::shared_ptr<const FetchableURISpecTree> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("parse_value")) return f(); @@ -650,7 +650,7 @@ struct MetadataSpecTreeKeyWrapper<FetchableURISpecTree> : virtual const std::shared_ptr<const URILabel> initial_label() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("initial_label")) return f(); @@ -660,7 +660,7 @@ struct MetadataSpecTreeKeyWrapper<FetchableURISpecTree> : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -670,7 +670,7 @@ struct MetadataSpecTreeKeyWrapper<FetchableURISpecTree> : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -680,7 +680,7 @@ struct MetadataSpecTreeKeyWrapper<FetchableURISpecTree> : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); @@ -704,7 +704,7 @@ struct MetadataSpecTreeKeyWrapper<DependencySpecTree> : virtual const std::shared_ptr<const DependencySpecTree> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("parse_value")) return f(); @@ -715,7 +715,7 @@ struct MetadataSpecTreeKeyWrapper<DependencySpecTree> : virtual const std::shared_ptr<const DependenciesLabelSequence> initial_labels() const PALUDIS_ATTRIBUTE((warn_unused_result)) { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = this->get_override("initial_labels")) return f(); @@ -725,7 +725,7 @@ struct MetadataSpecTreeKeyWrapper<DependencySpecTree> : virtual const std::string raw_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("raw_name")) return f(); @@ -735,7 +735,7 @@ struct MetadataSpecTreeKeyWrapper<DependencySpecTree> : virtual const std::string human_name() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("human_name")) return f(); @@ -745,7 +745,7 @@ struct MetadataSpecTreeKeyWrapper<DependencySpecTree> : virtual MetadataKeyType type() const { - Lock l(get_mutex()); + std::unique_lock<std::recursive_mutex> l(get_mutex()); if (bp::override f = get_override("type")) return f(); diff --git a/python/mutex.cc b/python/mutex.cc index e5eaaa4ce..5455f65f8 100644 --- a/python/mutex.cc +++ b/python/mutex.cc @@ -23,9 +23,9 @@ namespace paludis { namespace python { - Mutex & get_mutex() + std::recursive_mutex & get_mutex() { - static Mutex mutex; + static std::recursive_mutex mutex; return mutex; } } // namespace paludis::python diff --git a/python/mutex.hh b/python/mutex.hh index 8f026a846..57cab1379 100644 --- a/python/mutex.hh +++ b/python/mutex.hh @@ -20,15 +20,16 @@ #ifndef PALUDIS_GUARD_PYTHON_MUTEX_HH #define PALUDIS_GUARD_PYTHON_MUTEX_HH 1 -#include <paludis/util/mutex.hh> +#include <paludis/util/attributes.hh> +#include <mutex> namespace paludis { namespace python { //global mutex for thread safety. - Mutex & get_mutex() PALUDIS_VISIBLE; - } // namespace paludis::python -} // namespace paludis + std::recursive_mutex & get_mutex() PALUDIS_VISIBLE; + } +} #endif diff --git a/ruby/repository.cc b/ruby/repository.cc index a5733dab2..f32a27b18 100644 --- a/ruby/repository.cc +++ b/ruby/repository.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Ciaran McCreesh * Copyright (c) 2006, 2007, 2008 Richard Brown * Copyright (c) 2007 David Leverton * @@ -29,8 +29,6 @@ #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/set.hh> #include <paludis/util/sequence.hh> -#include <paludis/util/mutex.hh> -#include <paludis/util/condition_variable.hh> #include <paludis/util/make_named_values.hh> #include <ruby.h> #include <list> diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc index 51165aae0..d3b28f6cb 100644 --- a/src/clients/cave/cmd_execute_resolution.cc +++ b/src/clients/cave/cmd_execute_resolution.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -44,7 +44,6 @@ #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/wrapped_output_iterator.hh> #include <paludis/util/executor.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/timestamp.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/process.hh> @@ -88,6 +87,7 @@ #include <cstdlib> #include <algorithm> #include <unordered_map> +#include <mutex> using namespace paludis; using namespace cave; @@ -146,11 +146,11 @@ namespace }; std::string lock_pipe_command( - Mutex & mutex, + std::mutex & mutex, ProcessPipeCommandFunction f, const std::string & s) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); return f(s); } @@ -387,11 +387,11 @@ namespace } void set_output_manager( - Mutex & mutex, + std::recursive_mutex & mutex, JobActiveState & active_state, const std::shared_ptr<OutputManager> & o) { - Lock lock(mutex); + std::unique_lock<std::recursive_mutex> lock(mutex); active_state.set_output_manager(o); } @@ -427,9 +427,9 @@ namespace const int n_fetch_jobs, const PackageDepSpec & id_spec, const int x, const int y, const int f, const int s, bool normal_only, const bool was_target, - Mutex & job_mutex, + std::recursive_mutex & job_mutex, JobActiveState & active_state, - Mutex & executor_mutex) + std::mutex & executor_mutex) { Context context("When fetching for '" + stringify(id_spec) + "':"); @@ -490,9 +490,9 @@ namespace const int x, const int y, const int f, const int s, const bool was_target, - Mutex & job_mutex, + std::recursive_mutex & job_mutex, JobActiveState & active_state, - Mutex & executor_mutex) + std::mutex & executor_mutex) { Context context("When " + destination_string + " for '" + stringify(id_spec) + "':"); @@ -553,9 +553,9 @@ namespace const int x, const int y, const int f, const int s, const bool was_target, - Mutex & job_mutex, + std::recursive_mutex & job_mutex, JobActiveState & active_state, - Mutex & executor_mutex) + std::mutex & executor_mutex) { Context context("When removing '" + stringify(id_spec) + "':"); @@ -780,7 +780,7 @@ namespace struct ExecuteCounts { - Mutex mutex; + std::mutex mutex; int x_fetches, y_fetches, f_fetches, s_fetches, x_installs, y_installs, f_installs, s_installs; ExecuteCounts() : @@ -797,19 +797,19 @@ namespace void visit(const FetchJob &) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++y_fetches; } void visit(const InstallJob &) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++y_installs; } void visit(const UninstallJob &) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++y_installs; } }; @@ -834,8 +834,8 @@ namespace const ExecuteResolutionCommandLine & cmdline; const int n_fetch_jobs; ExecuteCounts & counts; - Mutex & job_mutex; - Mutex & executor_mutex; + std::recursive_mutex & job_mutex; + std::mutex & executor_mutex; const ExecuteOneVisitorPart part; int retcode; @@ -844,8 +844,8 @@ namespace const ExecuteResolutionCommandLine & c, const int n, ExecuteCounts & k, - Mutex & m, - Mutex & x, + std::recursive_mutex & m, + std::mutex & x, ExecuteOneVisitorPart p, int r) : env(e), @@ -901,7 +901,7 @@ namespace { const std::shared_ptr<JobActiveState> active_state(std::make_shared<JobActiveState>()); { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); install_item.set_state(active_state); } @@ -909,7 +909,7 @@ namespace counts.f_installs, counts.s_installs, false, install_item.was_target(), job_mutex, *active_state, executor_mutex)) { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); install_item.set_state(active_state->failed()); ++counts.f_installs; return 1; @@ -920,13 +920,13 @@ namespace counts.x_installs, counts.y_installs, counts.f_installs, counts.s_installs, install_item.was_target(), job_mutex, *active_state, executor_mutex)) { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); install_item.set_state(active_state->failed()); ++counts.f_installs; return 1; } - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); install_item.set_state(active_state->succeeded()); } break; @@ -956,7 +956,7 @@ namespace { const std::shared_ptr<JobActiveState> active_state(std::make_shared<JobActiveState>()); { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); uninstall_item.set_state(active_state); } @@ -967,13 +967,13 @@ namespace counts.f_installs, counts.s_installs, uninstall_item.was_target(), job_mutex, *active_state, executor_mutex)) { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); uninstall_item.set_state(active_state->failed()); ++counts.f_installs; return 1; } - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); uninstall_item.set_state(active_state->succeeded()); } break; @@ -1002,20 +1002,20 @@ namespace { const std::shared_ptr<JobActiveState> active_state(std::make_shared<JobActiveState>()); { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); fetch_item.set_state(active_state); } if (! do_fetch(env, cmdline, n_fetch_jobs, fetch_item.origin_id_spec(), counts.x_fetches, counts.y_fetches, counts.f_fetches, counts.s_fetches, true, fetch_item.was_target(), job_mutex, *active_state, executor_mutex)) { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); fetch_item.set_state(active_state->failed()); ++counts.f_fetches; return 1; } - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); fetch_item.set_state(active_state->succeeded()); } break; @@ -1257,7 +1257,7 @@ namespace const std::shared_ptr<ExecuteJob> job; const std::shared_ptr<JobLists> lists; JobRequirementIf require_if; - Mutex & global_retcode_mutex; + std::mutex & global_retcode_mutex; int & global_retcode; int local_retcode; ExecuteCounts & counts; @@ -1265,7 +1265,7 @@ namespace Timestamp last_flushed, last_output; - Mutex job_mutex; + std::recursive_mutex job_mutex; bool want, already_done; @@ -1277,7 +1277,7 @@ namespace const std::shared_ptr<ExecuteJob> & j, const std::shared_ptr<JobLists> & l, JobRequirementIf r, - Mutex & m, + std::mutex & m, int & rc, ExecuteCounts & k, std::string & h) : @@ -1364,7 +1364,7 @@ namespace int current_global_retcode; { - Lock lock(global_retcode_mutex); + std::unique_lock<std::mutex> lock(global_retcode_mutex); current_global_retcode = global_retcode; } @@ -1406,7 +1406,7 @@ namespace } else if (! already_done) { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); job->set_state(std::make_shared<JobSkippedState>()); } } @@ -1416,7 +1416,7 @@ namespace if (n_fetch_jobs == 0) return; - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); const std::shared_ptr<OutputManager> output_manager( job->state()->accept_returning<std::shared_ptr<OutputManager> >(GetOutputManager())); @@ -1463,7 +1463,7 @@ namespace void flush_threaded() { - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); const std::shared_ptr<OutputManager> output_manager( job->state()->accept_returning<std::shared_ptr<OutputManager> >(GetOutputManager())); @@ -1485,7 +1485,7 @@ namespace ExecuteOneVisitor execute(env, cmdline, n_fetch_jobs, counts, job_mutex, executor.exclusivity_mutex(), x1_post, local_retcode); local_retcode |= job->accept_returning<int>(execute); - Lock lock(job_mutex); + std::unique_lock<std::recursive_mutex> lock(job_mutex); const std::shared_ptr<OutputManager> output_manager( job->state()->accept_returning<std::shared_ptr<OutputManager> >(GetOutputManager())); @@ -1500,7 +1500,7 @@ namespace } { - Lock lock(global_retcode_mutex); + std::unique_lock<std::mutex> lock(global_retcode_mutex); global_retcode |= local_retcode; } @@ -1516,7 +1516,7 @@ namespace const int n_fetch_jobs) { int retcode(0); - Mutex retcode_mutex; + std::mutex retcode_mutex; ExecuteCounts counts; for (JobList<ExecuteJob>::ConstIterator c(lists->execute_job_list()->begin()), diff --git a/src/clients/cave/cmd_generate_metadata.cc b/src/clients/cave/cmd_generate_metadata.cc index 20551f46b..fde43b930 100644 --- a/src/clients/cave/cmd_generate_metadata.cc +++ b/src/clients/cave/cmd_generate_metadata.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2011 Ciaran McCreesh + * Copyright (c) 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -31,7 +31,6 @@ #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/accept_visitor.hh> #include <paludis/util/thread_pool.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/generator.hh> #include <paludis/filtered_generator.hh> @@ -48,6 +47,7 @@ #include <cstdlib> #include <iostream> #include <algorithm> +#include <mutex> #include <map> #include <unistd.h> @@ -111,7 +111,7 @@ namespace struct DisplayCallback { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::map<std::string, int> metadata; mutable int steps; int total; @@ -202,7 +202,7 @@ namespace if (! output) return; - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++steps; update(); } @@ -212,7 +212,7 @@ namespace if (! output) return; - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++metadata.insert(std::make_pair(stringify(e.repository()), 0)).first->second; update(); } @@ -230,14 +230,14 @@ namespace } }; - void worker(Mutex & mutex, PackageIDSequence::ConstIterator & i, const PackageIDSequence::ConstIterator & i_end, bool & fail, + void worker(std::mutex & mutex, PackageIDSequence::ConstIterator & i, const PackageIDSequence::ConstIterator & i_end, bool & fail, DisplayCallback & display_callback) { while (true) { std::shared_ptr<const PackageID> id; { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); if (i != i_end) id = *i++; } @@ -257,7 +257,7 @@ namespace } catch (const Exception & e) { - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); std::cerr << "When processing '" << **i << "' got exception '" << e.message() << "' (" << e.what() << ")" << std::endl; fail = true; break; @@ -300,7 +300,7 @@ GenerateMetadataCommand::run( const std::shared_ptr<const PackageIDSequence> ids((*env)[selection::AllVersionsSorted(g)]); bool fail(false); - Mutex mutex; + std::mutex mutex; PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()); { diff --git a/src/clients/cave/cmd_manage_search_index.cc b/src/clients/cave/cmd_manage_search_index.cc index 48e0f23d0..bc61138b4 100644 --- a/src/clients/cave/cmd_manage_search_index.cc +++ b/src/clients/cave/cmd_manage_search_index.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2010, 2011 Ciaran McCreesh + * Copyright (c) 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -47,7 +47,6 @@ #include <paludis/util/visitor_cast.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/accept_visitor.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <cstdlib> @@ -55,6 +54,7 @@ #include <algorithm> #include <list> #include <map> +#include <mutex> #include <unistd.h> #include "config.h" @@ -74,7 +74,7 @@ namespace struct DisplayCallback { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::map<std::string, int> metadata; mutable int steps; int total; @@ -165,7 +165,7 @@ namespace if (! output) return; - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++steps; stage = s.stage; update(); @@ -176,7 +176,7 @@ namespace if (! output) return; - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++metadata.insert(std::make_pair(stringify(e.repository()), 0)).first->second; update(); } diff --git a/src/clients/cave/cmd_resolve_display_callback.cc b/src/clients/cave/cmd_resolve_display_callback.cc index 7dd3c8ad3..18359b1af 100644 --- a/src/clients/cave/cmd_resolve_display_callback.cc +++ b/src/clients/cave/cmd_resolve_display_callback.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -23,6 +23,7 @@ #include <paludis/util/pimp-impl.hh> #include <paludis/util/fs_stat.hh> #include <iostream> +#include <mutex> #include <map> #include <unistd.h> @@ -34,7 +35,7 @@ namespace paludis template <> struct Imp<DisplayCallback> { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::map<std::string, int> metadata, steps; mutable std::string stage; mutable unsigned width; @@ -79,7 +80,7 @@ DisplayCallback::operator() (const ResolverRestart &) const if (! _imp->output) return; - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); ++_imp->steps.insert(std::make_pair("restarts", 0)).first->second; update(); } @@ -90,7 +91,7 @@ DisplayCallback::visit(const NotifierCallbackGeneratingMetadataEvent & e) const if (! _imp->output) return; - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); ++_imp->metadata.insert(std::make_pair(stringify(e.repository()), 0)).first->second; update(); } @@ -101,7 +102,7 @@ DisplayCallback::visit(const NotifierCallbackResolverStageEvent & e) const if (! _imp->output) return; - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); _imp->stage = e.stage() + ": "; update(); } @@ -112,7 +113,7 @@ DisplayCallback::visit(const NotifierCallbackResolverStepEvent &) const if (! _imp->output) return; - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); ++_imp->steps.insert(std::make_pair("steps", 0)).first->second; update(); } @@ -123,7 +124,7 @@ DisplayCallback::visit(const NotifierCallbackLinkageStepEvent & e) const if (! _imp->output) return; - Lock lock(_imp->mutex); + std::unique_lock<std::mutex> lock(_imp->mutex); if (e.location().stat().is_directory_or_symlink_to_directory()) ++_imp->steps.insert(std::make_pair("directories", 0)).first->second; else diff --git a/src/clients/cave/cmd_resolve_display_callback.hh b/src/clients/cave/cmd_resolve_display_callback.hh index 249c13d2b..c51165975 100644 --- a/src/clients/cave/cmd_resolve_display_callback.hh +++ b/src/clients/cave/cmd_resolve_display_callback.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -20,9 +20,8 @@ #ifndef PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_RESOLVE_DISPLAY_CALLBACK_HH #define PALUDIS_GUARD_SRC_CLIENTS_CAVE_CMD_RESOLVE_DISPLAY_CALLBACK_HH 1 -#include <paludis/util/mutex.hh> -#include <paludis/util/pimp.hh> #include <paludis/notifier_callback-fwd.hh> +#include <paludis/util/pimp.hh> #include <string> namespace paludis diff --git a/src/clients/cave/cmd_search.cc b/src/clients/cave/cmd_search.cc index 6afbb408a..9b87f89a7 100644 --- a/src/clients/cave/cmd_search.cc +++ b/src/clients/cave/cmd_search.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2010, 2011 Ciaran McCreesh + * Copyright (c) 2010, 2011, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -45,7 +45,6 @@ #include <paludis/util/wrapped_forward_iterator.hh> #include <paludis/util/indirect_iterator-impl.hh> #include <paludis/util/wrapped_output_iterator.hh> -#include <paludis/util/mutex.hh> #include <paludis/util/iterator_funcs.hh> #include <paludis/util/make_null_shared_ptr.hh> #include <paludis/util/stringify.hh> @@ -53,6 +52,7 @@ #include <cstdlib> #include <iostream> #include <algorithm> +#include <mutex> #include <set> #include <map> #include <unistd.h> @@ -134,7 +134,7 @@ namespace struct DisplayCallback { - mutable Mutex mutex; + mutable std::mutex mutex; mutable std::map<std::string, int> metadata; mutable int steps; mutable std::string stage; @@ -221,7 +221,7 @@ namespace if (! output) return; - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++steps; stage = s.stage; update(); @@ -232,7 +232,7 @@ namespace if (! output) return; - Lock lock(mutex); + std::unique_lock<std::mutex> lock(mutex); ++metadata.insert(std::make_pair(stringify(e.repository()), 0)).first->second; update(); } diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc index e29bfe3bc..6045cae27 100644 --- a/src/clients/cave/cmd_sync.cc +++ b/src/clients/cave/cmd_sync.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -21,10 +21,8 @@ #include "exceptions.hh" #include "colours.hh" #include "format_user_config.hh" -#include <paludis/util/mutex.hh> #include <paludis/util/named_value.hh> #include <paludis/util/make_named_values.hh> -#include <paludis/util/condition_variable.hh> #include <paludis/util/return_literal_function.hh> #include <paludis/util/executor.hh> #include <paludis/util/timestamp.hh> diff --git a/src/clients/cave/resolve_common.cc b/src/clients/cave/resolve_common.cc index 5043f2c1e..b1877179a 100644 --- a/src/clients/cave/resolve_common.cc +++ b/src/clients/cave/resolve_common.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009, 2010, 2011, 2012 Ciaran McCreesh + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -27,7 +27,6 @@ #include "command_command_line.hh" #include "parse_spec_with_nice_error.hh" -#include <paludis/util/mutex.hh> #include <paludis/util/stringify.hh> #include <paludis/util/make_named_values.hh> #include <paludis/util/system.hh> |