]> git.ipfire.org Git - thirdparty/squid.git/blame - src/base/RunnersRegistry.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / base / RunnersRegistry.cc
CommitLineData
bbc27441 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
bbc27441
AJ
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
f7f3304a 9#include "squid.h"
6d57128b 10#include "base/RunnersRegistry.h"
21b7990f 11#include <set>
6d57128b 12
21b7990f
AR
13/// a collection of unique runners, in no particular order
14typedef std::set<RegisteredRunner*> Runners;
15/// all known runners
16static Runners *TheRunners = NULL;
6d57128b 17
21b7990f 18/// safely returns registered runners, initializing structures as needed
6d57128b 19static Runners &
21b7990f 20GetRunners()
6d57128b 21{
21b7990f
AR
22 if (!TheRunners)
23 TheRunners = new Runners;
24 return *TheRunners;
6d57128b
AR
25}
26
27int
21b7990f 28RegisterRunner(RegisteredRunner *rr)
6d57128b 29{
21b7990f
AR
30 Runners &runners = GetRunners();
31 runners.insert(rr);
6d57128b
AR
32 return runners.size();
33}
34
21b7990f
AR
35void
36RunRegistered(const RegisteredRunner::Method &m)
6d57128b 37{
21b7990f 38 Runners &runners = GetRunners();
6d57128b
AR
39 typedef Runners::iterator RRI;
40 for (RRI i = runners.begin(); i != runners.end(); ++i)
21b7990f 41 ((*i)->*m)();
6d57128b 42
21b7990f
AR
43 if (m == &RegisteredRunner::finishShutdown) {
44 delete TheRunners;
45 TheRunners = NULL;
6d57128b
AR
46 }
47}
48
49bool
50UseThisStatic(const void *)
51{
52 return true;
53}
f53969cc 54