@@ -12,7 +12,7 @@ namespace stdsharp
1212{
1313 template <typename T, shared_lockable Lockable = std::shared_mutex>
1414 requires basic_lockable<Lockable>
15- class concurrent_object
15+ class synchronizer
1616 {
1717 public:
1818 using value_type = std::optional<T>;
@@ -22,7 +22,7 @@ namespace stdsharp
2222 requires copy_assignable<value_type>
2323 static constexpr void assign_value (
2424 value_type& object, //
25- const concurrent_object <T, OtherLockable>& other //
25+ const synchronizer <T, OtherLockable>& other //
2626 )
2727 {
2828 other.read ([&object](const value_type& obj) { object = obj; });
@@ -31,7 +31,7 @@ namespace stdsharp
3131 template <typename OtherLockable>
3232 requires move_assignable<value_type>
3333 static constexpr void
34- assign_value (value_type& object, concurrent_object <T, OtherLockable>&& other)
34+ assign_value (value_type& object, synchronizer <T, OtherLockable>&& other)
3535 {
3636 cpp_move (other).write ([&object](value_type&& obj) { object = cpp_move (obj); });
3737 }
@@ -40,19 +40,19 @@ namespace stdsharp
4040 static constexpr bool other_assignable =
4141 requires (value_type obj) { assign_value (obj, std::declval<Other>()); };
4242
43- static constexpr bool copy_assignable = other_assignable<const concurrent_object &>;
44- static constexpr bool move_assignable = other_assignable<concurrent_object >;
43+ static constexpr bool copy_assignable = other_assignable<const synchronizer &>;
44+ static constexpr bool move_assignable = other_assignable<synchronizer >;
4545
4646 template <typename Other>
4747 requires (other_assignable<Other>)
48- constexpr concurrent_object (const empty_t , Other&& other)
48+ constexpr synchronizer (const empty_t , Other&& other)
4949 {
5050 assign_value (object_, cpp_forward (other));
5151 }
5252
5353 template <typename Other>
5454 requires (other_assignable<Other>)
55- constexpr concurrent_object & assign_impl (Other&& other)
55+ constexpr synchronizer & assign_impl (Other&& other)
5656 {
5757 write ([&other](value_type& obj) { assign_value (obj, cpp_forward (other)); });
5858 return *this ;
@@ -71,13 +71,13 @@ namespace stdsharp
7171 struct write_fn
7272 {
7373 template <typename Func>
74- constexpr void operator ()(concurrent_object && instance, Func&& func) const
74+ constexpr void operator ()(synchronizer && instance, Func&& func) const
7575 {
7676 std::invoke (cpp_forward (func), cpp_move (instance).object_ );
7777 }
7878
7979 template <typename Func>
80- constexpr void operator ()(concurrent_object & instance, Func&& func) const
80+ constexpr void operator ()(synchronizer & instance, Func&& func) const
8181 {
8282 const std::unique_lock lock{instance.lockable ()};
8383 std::invoke (cpp_forward (func), instance.object_ );
@@ -87,18 +87,18 @@ namespace stdsharp
8787 public:
8888 using lock_type = Lockable;
8989
90- concurrent_object () = default ;
90+ synchronizer () = default ;
9191
9292 template <typename ... Args>
9393 requires std::constructible_from<T, Args...> && std::default_initializable<Lockable>
94- explicit constexpr concurrent_object (Args&&... t_arg): object_(cpp_forward(t_arg)...)
94+ explicit constexpr synchronizer (Args&&... t_arg): object_(cpp_forward(t_arg)...)
9595 {
9696 }
9797
9898 template <typename ... TArgs, typename ... LockArgs>
9999 requires std::constructible_from<T, TArgs...> &&
100100 std::constructible_from<Lockable, LockArgs...>
101- explicit constexpr concurrent_object (
101+ explicit constexpr synchronizer (
102102 const std::piecewise_construct_t tag,
103103 std::tuple<TArgs...> t_arg,
104104 std::tuple<LockArgs...> lock_arg
@@ -109,48 +109,48 @@ namespace stdsharp
109109
110110 template <typename Other>
111111 requires (other_assignable<Other>)
112- constexpr concurrent_object (Other&& other): concurrent_object (empty, cpp_forward(other))
112+ constexpr synchronizer (Other&& other): synchronizer (empty, cpp_forward(other))
113113 {
114114 }
115115
116- constexpr concurrent_object (const concurrent_object & other)
116+ constexpr synchronizer (const synchronizer & other)
117117 requires copy_assignable
118- : concurrent_object (empty, other)
118+ : synchronizer (empty, other)
119119 {
120120 }
121121
122- constexpr concurrent_object (concurrent_object && other) noexcept (false )
122+ constexpr synchronizer (synchronizer && other) noexcept (false )
123123 requires move_assignable
124- : concurrent_object (empty, cpp_move(other))
124+ : synchronizer (empty, cpp_move(other))
125125 {
126126 }
127127
128128 template <typename Other>
129129 requires (other_assignable<Other>)
130- constexpr concurrent_object & operator =(Other&& other)
130+ constexpr synchronizer & operator =(Other&& other)
131131 {
132132 assign_impl (cpp_forward (other));
133133 return *this ;
134134 }
135135
136- constexpr concurrent_object & operator =(const concurrent_object & other)
136+ constexpr synchronizer & operator =(const synchronizer & other)
137137 requires copy_assignable
138138 {
139139 if (this != &other) assign_impl (other);
140140 return *this ;
141141 }
142142
143- constexpr concurrent_object & operator =(concurrent_object && other) noexcept (false )
143+ constexpr synchronizer & operator =(synchronizer && other) noexcept (false )
144144 requires move_assignable
145145 {
146146 if (this != &other) assign_impl (cpp_move (other));
147147 return *this ;
148148 }
149149
150- ~concurrent_object () = default ;
150+ ~synchronizer () = default ;
151151
152152 template <typename OtherLockable>
153- constexpr void swap (concurrent_object <T, OtherLockable>& other) //
153+ constexpr void swap (synchronizer <T, OtherLockable>& other) //
154154 requires std::swappable_with<
155155 value_type,
156156 typename std::remove_reference_t<decltype(other)>::value_type // clang-format off
@@ -171,7 +171,7 @@ namespace stdsharp
171171 template <std::invocable<const value_type> Func>
172172 constexpr void read (Func&& func) const &&
173173 {
174- read_fn{}(static_cast <const concurrent_object &&>(*this ), cpp_forward (func));
174+ read_fn{}(static_cast <const synchronizer &&>(*this ), cpp_forward (func));
175175 }
176176
177177 template <std::invocable<value_type&> Func>
@@ -196,40 +196,32 @@ namespace stdsharp
196196 };
197197
198198 template <typename T>
199- concurrent_object (T&&) -> concurrent_object <std::decay_t <T>>;
199+ synchronizer (T&&) -> synchronizer <std::decay_t <T>>;
200200
201201 namespace reflection
202202 {
203203 template <typename T, typename U>
204- inline constexpr auto function<concurrent_object <T, U>> =
205- member<concurrent_object <T, U>>::template func_reflect<" read" _ltr, " write" _ltr>(
204+ inline constexpr auto function<synchronizer <T, U>> =
205+ member<synchronizer <T, U>>::template func_reflect<" read" _ltr, " write" _ltr>(
206206 [](auto && v, auto &&... args) //
207207 noexcept ( //
208- noexcept (
209- cast_fwd<concurrent_object<T, U>>(cpp_forward(v)).read(cpp_forward(args)...)
208+ noexcept (cast_fwd<synchronizer<T, U>>(cpp_forward(v)).read(cpp_forward(args)...)
210209 )
211210 ) -> //
212211 decltype( //
213- cast_fwd<concurrent_object <T, U>>(cpp_forward(v)).read(cpp_forward(args)...)
212+ cast_fwd<synchronizer <T, U>>(cpp_forward(v)).read(cpp_forward(args)...)
214213 ) //
215- {
216- return cast_fwd<concurrent_object<T, U>>(cpp_forward (v))
217- .read (cpp_forward (args)...);
218- },
214+ { return cast_fwd<synchronizer<T, U>>(cpp_forward (v)).read (cpp_forward (args)...); },
219215 [](auto && v, auto &&... args) //
220216 noexcept ( //
221217 noexcept ( //
222- cast_fwd<concurrent_object<T, U>>(cpp_forward(v))
223- .write(cpp_forward(args)...)
218+ cast_fwd<synchronizer<T, U>>(cpp_forward(v)).write(cpp_forward(args)...)
224219 )
225220 ) -> //
226221 decltype( //
227- cast_fwd<concurrent_object <T, U>>(cpp_forward(v)).write(cpp_forward(args)...)
222+ cast_fwd<synchronizer <T, U>>(cpp_forward(v)).write(cpp_forward(args)...)
228223 ) //
229- {
230- return cast_fwd<concurrent_object<T, U>>(cpp_forward (v))
231- .write (cpp_forward (args)...);
232- }
224+ { return cast_fwd<synchronizer<T, U>>(cpp_forward (v)).write (cpp_forward (args)...); }
233225 );
234226 }
235227}
0 commit comments