DiskIOModule.cc
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/* DEBUG: section 92 Storage File System */
10
11#include "squid.h"
12#include "DiskIOModule.h"
13#if HAVE_DISKIO_MODULE_AIO
15#endif
16#if HAVE_DISKIO_MODULE_BLOCKING
18#endif
19#if HAVE_DISKIO_MODULE_DISKDAEMON
21#endif
22#if HAVE_DISKIO_MODULE_DISKTHREADS
24#endif
25#if HAVE_DISKIO_MODULE_IPCIO
27#endif
28#if HAVE_DISKIO_MODULE_MMAPPED
30#endif
31
32std::vector<DiskIOModule*> *DiskIOModule::_Modules = nullptr;
33
34//DiskIOModule() : initialised (false) {}
35
37{
42}
43
44void
46{
47#if HAVE_DISKIO_MODULE_AIO
48 AIODiskIOModule::GetInstance();
49#endif
50#if HAVE_DISKIO_MODULE_BLOCKING
52#endif
53#if HAVE_DISKIO_MODULE_DISKDAEMON
55#endif
56#if HAVE_DISKIO_MODULE_DISKTHREADS
58#endif
59#if HAVE_DISKIO_MODULE_IPCIO
61#endif
62#if HAVE_DISKIO_MODULE_MMAPPED
64#endif
65
66 for (iterator i = GetModules().begin(); i != GetModules().end(); ++i)
67 /* Call the FS to set up capabilities and initialize the FS driver */
68 (*i)->init();
69}
70
71void
73{
74 iterator i = GetModules().begin();
75
76 while (i != GetModules().end()) {
77 assert(strcmp((*i)->type(), instance.type()) != 0);
78 ++i;
79 }
80
81 GetModules().push_back (&instance);
82}
83
84std::vector<DiskIOModule *> const &
86{
87 return GetModules();
88}
89
90std::vector<DiskIOModule*> &
92{
93 if (!_Modules)
94 _Modules = new std::vector<DiskIOModule *>;
95
96 return *_Modules;
97}
98
103void
105{
106 while (!GetModules().empty()) {
107 DiskIOModule *fs = GetModules().back();
108 GetModules().pop_back();
109 fs->gracefulShutdown();
110 }
111}
112
114DiskIOModule::Find(char const *type)
115{
116 for (iterator i = GetModules().begin(); i != GetModules().end(); ++i)
117 if (strcasecmp(type, (*i)->type()) == 0)
118 return *i;
119
120 return nullptr;
121}
122
125{
127 DiskIOModule * result;
128 result = Find("DiskThreads");
129 if (nullptr == result)
130 result = Find("DiskDaemon");
131 if (nullptr == result)
132 result = Find("AIO");
133 if (nullptr == result)
134 result = Find("Blocking");
135 return result;
136}
137
#define assert(EX)
Definition: assert.h:17
static BlockingDiskIOModule & GetInstance()
static DiskDaemonDiskIOModule & GetInstance()
virtual void gracefulShutdown()=0
static DiskIOModule * Find(char const *type)
static void ModuleAdd(DiskIOModule &)
Definition: DiskIOModule.cc:72
static void FreeAllModules()
std::vector< DiskIOModule * >::iterator iterator
Definition: DiskIOModule.h:36
static std::vector< DiskIOModule * > const & Modules()
Definition: DiskIOModule.cc:85
static std::vector< DiskIOModule * > * _Modules
Definition: DiskIOModule.h:57
static DiskIOModule * FindDefault()
virtual char const * type() const =0
static void SetupAllModules()
Definition: DiskIOModule.cc:45
static std::vector< DiskIOModule * > & GetModules()
Definition: DiskIOModule.cc:91
static DiskThreadsDiskIOModule & GetInstance()
static IpcIoDiskIOModule & GetInstance()
static MmappedDiskIOModule & GetInstance()
static CacheManager * instance

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors