source: squid-ssl/trunk/fuentes/src/DiskIO/DiskIOModule.cc @ 5495

Last change on this file since 5495 was 5495, checked in by Juanma, 4 years ago

Initial release

File size: 2.2 KB
Line 
1/*
2 * Copyright (C) 1996-2015 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
14std::vector<DiskIOModule*> *DiskIOModule::_Modules = NULL;
15
16//DiskIOModule() : initialised (false) {}
17
18DiskIOModule::DiskIOModule()
19{
20    /** We cannot call ModuleAdd(*this)
21     * here as the virtual methods are not yet available.
22     * We leave that to PokeAllModules() later.
23     */
24}
25
26void
27DiskIOModule::SetupAllModules()
28{
29    DiskIOModule::PokeAllModules();
30
31    for (iterator i = GetModules().begin(); i != GetModules().end(); ++i)
32        /* Call the FS to set up capabilities and initialize the FS driver */
33        (*i)->init();
34}
35
36void
37DiskIOModule::ModuleAdd(DiskIOModule &instance)
38{
39    iterator i = GetModules().begin();
40
41    while (i != GetModules().end()) {
42        assert(strcmp((*i)->type(), instance.type()) != 0);
43        ++i;
44    }
45
46    GetModules().push_back (&instance);
47}
48
49std::vector<DiskIOModule *> const &
50DiskIOModule::Modules()
51{
52    return GetModules();
53}
54
55std::vector<DiskIOModule*> &
56DiskIOModule::GetModules()
57{
58    if (!_Modules)
59        _Modules = new std::vector<DiskIOModule *>;
60
61    return *_Modules;
62}
63
64/**
65 * Called when a graceful shutdown is to occur
66 * of each fs module.
67 */
68void
69DiskIOModule::FreeAllModules()
70{
71    while (!GetModules().empty()) {
72        DiskIOModule *fs = GetModules().back();
73        GetModules().pop_back();
74        fs->gracefulShutdown();
75    }
76}
77
78DiskIOModule *
79DiskIOModule::Find(char const *type)
80{
81    for (iterator i = GetModules().begin(); i != GetModules().end(); ++i)
82        if (strcasecmp(type, (*i)->type()) == 0)
83            return *i;
84
85    return NULL;
86}
87
88DiskIOModule *
89DiskIOModule::FindDefault()
90{
91    /** Best IO options are in order: */
92    DiskIOModule * result;
93    result = Find("DiskThreads");
94    if (NULL == result)
95        result = Find("DiskDaemon");
96    if (NULL == result)
97        result = Find("AIO");
98    if (NULL == result)
99        result = Find("Blocking");
100    return result;
101}
102
Note: See TracBrowser for help on using the repository browser.