Skip to content

Commit ad53544

Browse files
committed
caved in
1 parent 5dbfa8d commit ad53544

File tree

1 file changed

+6
-31
lines changed

1 file changed

+6
-31
lines changed

libmamba/src/core/logging.cpp

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,12 @@ namespace mamba::logging
1919
{
2020
namespace
2121
{
22-
// We need the mutex to be constructible compile-time to allow using `constinit`
23-
// and avoid static-init-fiasco.
24-
// But depending on the implementation it is not always possible, so we pay
25-
// the locking cost in these platforms.
26-
/*namespace
27-
{
28-
template<class T>
29-
consteval auto try_constant_init() -> T
30-
{
31-
constexpr T x{};
32-
return x;
33-
}
34-
35-
template <class T>
36-
concept can_be_constinit = requires() { try_constant_init<T>(); };
37-
38-
static_assert(can_be_constinit<std::mutex>);
39-
40-
struct X
41-
{
42-
std::shared_ptr<int> value = std::make_shared<int>(42);
43-
};
44-
45-
static_assert(not can_be_constinit<X>);
46-
47-
using params_mutex = std::
48-
conditional_t<can_be_constinit<std::shared_mutex>, std::shared_mutex, std::mutex>;
49-
50-
}*/
51-
52-
constinit util::synchronized_value<LoggingParams, std::shared_mutex> logging_params;
22+
// FIXME:
23+
// This should really be using `std::shared_mutex` but on some compilers they
24+
// dont accept `constinit` here, so until this is fixed we'll lose performance using
25+
// `std::mutex` when we mostly are reading data, not modifying,
26+
// but at least we maintain correctness and avoid static-init fiasco.
27+
constinit util::synchronized_value<LoggingParams, std::mutex> logging_params;
5328

5429
// IMPRTANT NOTE:
5530
// The handler MUST NOT be protected from concurrent calls at this level

0 commit comments

Comments
 (0)