1010#include < array> // std::array
1111#include < filesystem> // std::filesystem
1212#include < functional> // std::function, std::reference_wrapper, std::cref
13+ #include < mutex> // std::unique_lock
1314#include < optional> // std::optional
1415#include < shared_mutex> // std::shared_mutex, std::shared_lock
1516#include < string> // std::string
@@ -50,7 +51,7 @@ class SOURCEMETA_ONE_BUILD_EXPORT Build {
5051 const std::vector<std::filesystem::path> &dependencies)
5152 -> bool {
5253 const auto &destination_string{destination.native ()};
53- std::shared_lock lock{this ->mutex };
54+ std::unique_lock lock{this ->mutex };
5455 const auto cached_match{this ->entries_ .find (destination_string)};
5556 if (cached_match != this ->entries_ .end ()) {
5657 const auto &entry{cached_match->second };
@@ -69,8 +70,7 @@ class SOURCEMETA_ONE_BUILD_EXPORT Build {
6970 }
7071
7172 if (this ->dispatch_is_cached (entry, static_dependencies_match)) {
72- lock.unlock ();
73- this ->track (destination);
73+ this ->track_unsafe (destination);
7474 return false ;
7575 }
7676 }
@@ -107,7 +107,7 @@ class SOURCEMETA_ONE_BUILD_EXPORT Build {
107107 const Context &context, const DependencyTypes &...dependencies)
108108 -> bool {
109109 const auto &destination_string{destination.native ()};
110- std::shared_lock lock{this ->mutex };
110+ std::unique_lock lock{this ->mutex };
111111 const auto cached_match{this ->entries_ .find (destination_string)};
112112 if (cached_match != this ->entries_ .end ()) {
113113 const auto &entry{cached_match->second };
@@ -131,8 +131,7 @@ class SOURCEMETA_ONE_BUILD_EXPORT Build {
131131 }
132132
133133 if (this ->dispatch_is_cached (entry, static_dependencies_match)) {
134- lock.unlock ();
135- this ->track (destination);
134+ this ->track_unsafe (destination);
136135 return false ;
137136 }
138137 }
@@ -187,6 +186,7 @@ class SOURCEMETA_ONE_BUILD_EXPORT Build {
187186 std::vector<std::filesystem::path> &&static_dependencies,
188187 std::vector<std::filesystem::path> &&dynamic_dependencies)
189188 -> void ;
189+ auto track_unsafe (const std::filesystem::path &path) -> void;
190190
191191 std::filesystem::path root;
192192 std::string root_string;
0 commit comments