1212
1313#include < boost/capy/detail/config.hpp>
1414#include < boost/capy/detail/frame_memory_resource.hpp>
15- #include < boost/capy/detail/service_slot.hpp>
1615#include < boost/capy/detail/type_id.hpp>
1716#include < boost/capy/concept/executor.hpp>
18- #include < atomic>
1917#include < concepts>
2018#include < memory>
2119#include < memory_resource>
@@ -225,14 +223,6 @@ class BOOST_CAPY_DECL
225223 template <class T >
226224 T* find_service () const noexcept
227225 {
228- auto id = detail::service_slot<T>();
229- if (id < max_service_slots)
230- {
231- auto * p = slots_[id].load (
232- std::memory_order_acquire);
233- if (p)
234- return static_cast <T*>(p);
235- }
236226 std::lock_guard<std::mutex> lock (mutex_);
237227 return static_cast <T*>(find_impl (detail::type_id<T>()));
238228 }
@@ -265,24 +255,6 @@ class BOOST_CAPY_DECL
265255 " T must derive from service" );
266256 static_assert (std::is_constructible<T, execution_context&>::value,
267257 " T must be constructible from execution_context&" );
268- if constexpr (get_key<T>::value)
269- {
270- static_assert (
271- std::is_convertible<T&, typename get_key<T>::type&>::value,
272- " T& must be convertible to key_type&" );
273- }
274-
275- // Fast path: O(1) slot lookup
276- {
277- auto id = detail::service_slot<T>();
278- if (id < max_service_slots)
279- {
280- auto * p = slots_[id].load (
281- std::memory_order_acquire);
282- if (p)
283- return static_cast <T&>(*p);
284- }
285- }
286258
287259 struct impl : factory
288260 {
@@ -291,11 +263,7 @@ class BOOST_CAPY_DECL
291263 detail::type_id<T>(),
292264 get_key<T>::value
293265 ? detail::type_id<typename get_key<T>::type>()
294- : detail::type_id<T>(),
295- detail::service_slot<T>(),
296- get_key<T>::value
297- ? detail::service_slot<typename get_key<T>::type>()
298- : detail::service_slot<T>())
266+ : detail::type_id<T>())
299267 {
300268 }
301269
@@ -357,11 +325,7 @@ class BOOST_CAPY_DECL
357325 detail::type_id<T>(),
358326 get_key<T>::value
359327 ? detail::type_id<typename get_key<T>::type>()
360- : detail::type_id<T>(),
361- detail::service_slot<T>(),
362- get_key<T>::value
363- ? detail::service_slot<typename get_key<T>::type>()
364- : detail::service_slot<T>())
328+ : detail::type_id<T>())
365329 , args_(std::forward<Args>(a)...)
366330 {
367331 }
@@ -541,16 +505,11 @@ class BOOST_CAPY_DECL
541505 detail::type_index t0;
542506 detail::type_index t1;
543507 BOOST_CAPY_MSVC_WARNING_POP
544- std::size_t slot0;
545- std::size_t slot1;
546508
547509 factory (
548510 detail::type_info const & t0_,
549- detail::type_info const & t1_,
550- std::size_t s0,
551- std::size_t s1)
511+ detail::type_info const & t1_)
552512 : t0(t0_), t1(t1_)
553- , slot0(s0), slot1(s1)
554513 {
555514 }
556515
@@ -564,7 +523,7 @@ class BOOST_CAPY_DECL
564523 service& use_service_impl (factory& f);
565524 service& make_service_impl (factory& f);
566525
567- // warning C4251: std::mutex, std::shared_ptr, std::atomic need dll-interface
526+ // warning C4251: std::mutex, std::shared_ptr need dll-interface
568527 BOOST_CAPY_MSVC_WARNING_PUSH
569528 BOOST_CAPY_MSVC_WARNING_DISABLE (4251 )
570529 mutable std::mutex mutex_;
@@ -573,12 +532,6 @@ class BOOST_CAPY_DECL
573532 std::pmr::memory_resource* frame_alloc_ = nullptr ;
574533 service* head_ = nullptr ;
575534 bool shutdown_ = false ;
576-
577- static constexpr std::size_t max_service_slots = 32 ;
578- BOOST_CAPY_MSVC_WARNING_PUSH
579- BOOST_CAPY_MSVC_WARNING_DISABLE (4251 )
580- std::atomic<service*> slots_[max_service_slots] = {};
581- BOOST_CAPY_MSVC_WARNING_POP
582535};
583536
584537template < typename Derived >
0 commit comments