24#ifndef WEAK_REQUIRES_SERVICE_GUARD
25#define WEAK_REQUIRES_SERVICE_GUARD
131template <
typename Service,
const std::string &
container,
132 const std::string &service_name>
165 const std::function<bool(Service *)>
function;
181 std::string(
"dynamic_loader_services_loaded_notification.") +
182 container + std::string(
"_") + service_name;
195 if (
hton->function(svc))
return true;
196 hton->function_called =
true;
210 if (!
hton->function_called) {
211 for (
unsigned idx = 0; idx <
count; idx++) {
213 if (svc.starts_with(service_name) &&
214 svc.length() > service_name.length() &&
215 svc[service_name.length()] ==
'.')
253 std::function<
bool(Service *)> func_arg) {
255 assert(
hton ==
nullptr);
260 if (!
hton->function_called) {
262 x, dynamic_loader_services_loaded_notification)
notify
264 if (reg_reg_arg->register_service(
265 hton->listener_name.c_str(),
268 x, dynamic_loader_services_loaded_notification))))
298 registry_registration_arg,
299 std::function<
bool(Service *)> deinit_func_arg) {
301 if (
hton->function_called) {
303 if (svc.
is_valid() && deinit_func_arg(svc))
return true;
306 registry_registration_arg->unregister(
hton->listener_name.c_str()))
Wraps my_h_service struct conforming ABI into RAII C++ object with ability to cast to desired service...
Definition: my_service.h:35
bool is_valid() const
Definition: my_service.h:104
A utility class to implement a delayed service reference.
Definition: weak_service_reference.h:133
static weak_service_reference< Service, container, service_name > * hton
A single instance of the class to hold (and initialize) some data at init time.
Definition: weak_service_reference.h:138
static bool init(const mysql_service_registry_t *reg_arg, const mysql_service_registry_registration_t *reg_reg_arg, std::function< bool(Service *)> func_arg)
Initialize the weak reference class.
Definition: weak_service_reference.h:251
std::string listener_name
A service_loaded listener implementation name of the following format: dynamic_loader_services_loaded...
Definition: weak_service_reference.h:171
static mysql_service_status_t notify(const char **services, unsigned int count) noexcept
An implementation for the dynamic_loader_services_loaded_notification::notify service method.
Definition: weak_service_reference.h:209
std::atomic< bool > function_called
A flag if the init callback function has been called.
Definition: weak_service_reference.h:161
static bool call_function()
Helper function to take a reference to the service needed and call the init callback function.
Definition: weak_service_reference.h:192
static bool callback_registered
A flag stating if the callback service implementation listening for new implementations of the servic...
Definition: weak_service_reference.h:150
static const mysql_service_registry_t * registry
We need to store a reference to the registry since the init callback needs it.
Definition: weak_service_reference.h:145
weak_service_reference(std::function< bool(Service *)> &func_arg)
A private constructor for the hton.
Definition: weak_service_reference.h:178
const std::function< bool(Service *)> function
The init callback reference.
Definition: weak_service_reference.h:165
static bool deinit(const mysql_service_registry_t *registry_arg, const mysql_service_registry_registration_t *registry_registration_arg, std::function< bool(Service *)> deinit_func_arg)
Deinitializes a weak reference caller class.
Definition: weak_service_reference.h:296
Connection event tracking.
struct my_h_service_imp * my_h_service
A handle type for acquired Service.
Definition: registry.h:33
static int count
Definition: myisam_ftdump.cc:45
const mysql_service_registry_registration_t * registry_registration
Definition: atomics_array.h:39
Definition: services.cc:40
#define SERVICE_TYPE(name)
Generates the standard Service type name.
Definition: service.h:76
Specifies macros to define Service Implementations.
#define BEGIN_SERVICE_IMPLEMENTATION(component, service)
Declares a Service Implementation.
Definition: service_implementation.h:62
#define END_SERVICE_IMPLEMENTATION()
A macro to end the last declaration of a Service Implementation.
Definition: service_implementation.h:67
#define DEFINE_BOOL_METHOD(name, args)
A short macro to define method that returns bool, which is the most common case.
Definition: service_implementation.h:88
#define SERVICE_IMPLEMENTATION(component, service)
Reference to the name of the service implementation variable.
Definition: service_implementation.h:51