RunnersRegistry.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_BASE_RUNNERSREGISTRY_H
10#define SQUID_BASE_RUNNERSREGISTRY_H
11
38{
39public:
40 /* Related methods below are declared in their calling order */
41
42 /* Configuration events */
43
46 virtual void bootstrapConfig() {}
47
51 virtual void finalizeConfig() {}
52
55 virtual void claimMemoryNeeds() {}
56
60 virtual void useConfig() {}
61
62 /* Reconfiguration events */
63
67 virtual void startReconfigure() {}
68
71 virtual void syncConfig() {}
72
73 /* Shutdown events */
74
78 virtual void startShutdown() {}
79
84 virtual void endingShutdown() {}
85
88 virtual ~RegisteredRunner() {}
89
91 virtual void finishShutdown() {}
92
94 typedef void (RegisteredRunner::*Method)();
95
96};
97
100
104
107{
108public:
110
111protected:
112 void registerRunner();
113 void unregisterRunner();
114};
115
117#define RunRegisteredHere(m) \
118 debugs(1, 2, "running " # m); \
119 RunRegistered(&m)
120
123#define NameRunnerRegistrator_(Namespace, ClassName) \
124 Register ## ClassName ## In ## Namespace()
125
128#define DefineRunnerRegistrator_(Namespace, ClassName, Constructor) \
129 void NameRunnerRegistrator_(Namespace, ClassName); \
130 void NameRunnerRegistrator_(Namespace, ClassName) { \
131 const auto registered = RegisterRunner(new Constructor); \
132 assert(registered); \
133 }
134
139#define DefineRunnerRegistratorIn(Namespace, ClassName) \
140 DefineRunnerRegistrator_(Namespace, ClassName, Namespace::ClassName)
141
146#define DefineRunnerRegistrator(ClassName) \
147 DefineRunnerRegistrator_(Global, ClassName, ClassName)
148
151#define CallRunnerRegistratorIn(Namespace, ClassName) \
152 do { \
153 void NameRunnerRegistrator_(Namespace, ClassName); \
154 NameRunnerRegistrator_(Namespace, ClassName); \
155 } while (false)
156
159#define CallRunnerRegistrator(ClassName) \
160 CallRunnerRegistratorIn(Global, ClassName)
161
162#endif /* SQUID_BASE_RUNNERSREGISTRY_H */
163
void RunRegistered(const RegisteredRunner::Method &m)
bool RegisterRunner(RegisteredRunner *rr)
registers a given runner with the given registry and returns true on success
A RegisteredRunner with lifetime determined by forces outside the Registry.
void unregisterRunner()
unregisters self; safe to call multiple times
~IndependentRunner() override
virtual void syncConfig()
virtual void bootstrapConfig()
virtual void claimMemoryNeeds()
void(RegisteredRunner::* Method)()
a pointer to one of the above notification methods
virtual void startShutdown()
virtual ~RegisteredRunner()
virtual void finalizeConfig()
virtual void endingShutdown()
virtual void finishShutdown()
Meant for cleanup of services needed by the already destroyed objects.
virtual void useConfig()
virtual void startReconfigure()

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors