From 9bd3e550dcbec2d1fd71bc851eaaefcba82ab5ef Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sat, 18 Apr 2026 16:25:14 +0200 Subject: [PATCH] BufferProvider: improve configuration of thread-local dispatch Since thread_local implies a static setup, we need a way how to build a new service instance. Usually this would be a default construction, yet there might be services with special init requirements. Using an explicit template parameter for this setup configuration allows to make the primary template parameter just the service itself, which makes the default usage much clearer. --- src/lib/local-slice.hpp | 21 +++++++++++------ tests/lib/local-slice-test.cpp | 9 +------- wiki/thinkPad.ichthyo.mm | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/src/lib/local-slice.hpp b/src/lib/local-slice.hpp index 83855218d..22c8132af 100644 --- a/src/lib/local-slice.hpp +++ b/src/lib/local-slice.hpp @@ -41,22 +41,29 @@ namespace lib { + + /** Extension point for LocalSlice: Service initialisation */ + template + struct LocalSlice_DefaultSetup + { + using Service = SRV; + static Service init() { return Service(); } + }; + /** * Common access point to thread-local service instances. - * @tparam CONF static config / setup to initialise the service. + * @tparam CONF setup to initialise the service. */ - template - class LocalSlice + template> + struct LocalSlice { - using Service = CONF::Service; - - public: LocalSlice() = default; - // using default copy/assignment + using Service = CONF::Service; + /** service access */ Service& operator*() const diff --git a/tests/lib/local-slice-test.cpp b/tests/lib/local-slice-test.cpp index 86bda458a..36761565c 100644 --- a/tests/lib/local-slice-test.cpp +++ b/tests/lib/local-slice-test.cpp @@ -57,14 +57,7 @@ namespace test { } }; - struct DummySetup - { - using Service = DummyBackend; - - static Service init() { return Service(); } - }; - - using DummySlice = LocalSlice; + using DummySlice = LocalSlice; /** diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 2b4513227..b17a58fa2 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -144308,6 +144308,47 @@ StM_bind(Builder<R1> b1, Extension<R1,R2> extension) + + + + + + + + + + + + +

+ man muß den aktuellen Namespace schließen, in lib gehen, dort die explizite Spezialisierung definieren... +

+ + +
+ +
+ + + + + + + + + +

+ direkt bei LocalSlice definiert; erzeugt eine default-konstruierte Instanz vom Service +

+ + +
+
+ + + +
+