File tree Expand file tree Collapse file tree 1 file changed +6
-31
lines changed Expand file tree Collapse file tree 1 file changed +6
-31
lines changed Original file line number Diff line number Diff line change @@ -19,37 +19,12 @@ namespace mamba::logging
19
19
{
20
20
namespace
21
21
{
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;
53
28
54
29
// IMPRTANT NOTE:
55
30
// The handler MUST NOT be protected from concurrent calls at this level
You can’t perform that action at this time.
0 commit comments