// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include "i_shared_threading_service.h" #include "shared_threading_service_config.h" #include #include #include namespace vespalib { class IDestructorCallback; } namespace proton { /** * Class containing the thread executors that are shared across all document dbs. */ class SharedThreadingService : public ISharedThreadingService { private: using Registration = std::unique_ptr; FNET_Transport & _transport; std::shared_ptr _shared; std::unique_ptr _field_writer; std::unique_ptr _invokeService; std::vector _invokeRegistrations; storage::spi::BucketExecutor& _bucket_executor; public: SharedThreadingService(const SharedThreadingServiceConfig& cfg, FNET_Transport& transport, storage::spi::BucketExecutor& bucket_executor); ~SharedThreadingService() override; std::shared_ptr shared_raw() { return _shared; } void sync_all_executors(); vespalib::ThreadExecutor& shared() override { return *_shared; } vespalib::ISequencedTaskExecutor& field_writer() override { return *_field_writer; } vespalib::InvokeService & invokeService() override { return *_invokeService; } FNET_Transport & transport() override { return _transport; } storage::spi::BucketExecutor& bucket_executor() override { return _bucket_executor; } const std::atomic & nowRef() const override; }; }