]>
Commit | Line | Data |
---|---|---|
b9ae18aa | 1 | /* |
1f7b830e | 2 | * Copyright (C) 1996-2025 The Squid Software Foundation and contributors |
b9ae18aa | 3 | * |
bbc27441 AJ |
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. | |
b9ae18aa | 7 | */ |
8 | ||
ff9d9458 FC |
9 | #ifndef SQUID_SRC_DISKIO_DISKIOSTRATEGY_H |
10 | #define SQUID_SRC_DISKIO_DISKIOSTRATEGY_H | |
b9ae18aa | 11 | |
8bf217bd | 12 | #include "base/RefCount.h" |
582c2af2 | 13 | #include "Store.h" |
b9ae18aa | 14 | |
15 | class DiskFile; | |
16 | ||
17 | class ConfigOption; | |
18 | ||
19 | class DiskIOStrategy | |
20 | { | |
21 | ||
22 | public: | |
26ac0430 | 23 | virtual ~DiskIOStrategy() {} |
b9ae18aa | 24 | |
63be0a78 | 25 | /** Can the IO Strategy handle more requests ? */ |
b9ae18aa | 26 | virtual bool shedLoad() = 0; |
63be0a78 | 27 | |
28 | /** What is the current load? 999 = 99.9% */ | |
b9ae18aa | 29 | virtual int load() = 0; |
63be0a78 | 30 | |
31 | /** Return a handle for performing IO operations */ | |
32 | virtual RefCount<DiskFile> newFile(char const *path) = 0; | |
33 | ||
34 | /** flush all IO operations */ | |
b9ae18aa | 35 | virtual void sync() {} |
36 | ||
c521ad17 DK |
37 | /** whether the IO Strategy can use unlinkd */ |
38 | virtual bool unlinkdUseful() const = 0; | |
39 | ||
63be0a78 | 40 | /** unlink a file by path */ |
41 | virtual void unlinkFile(char const *) = 0; | |
b9ae18aa | 42 | |
63be0a78 | 43 | /** perform any pending callbacks */ |
b9ae18aa | 44 | virtual int callback() { return 0; } |
45 | ||
63be0a78 | 46 | /** Init per-instance logic */ |
b9ae18aa | 47 | virtual void init() {} |
48 | ||
63be0a78 | 49 | /** cachemgr output on the IO instance stats */ |
ced8def3 | 50 | virtual void statfs(StoreEntry &) const {} |
b9ae18aa | 51 | |
63be0a78 | 52 | /** module specific options */ |
aee3523a | 53 | virtual ConfigOption *getOptionTree() const {return nullptr;} |
b9ae18aa | 54 | }; |
55 | ||
56 | /* Because we need the DiskFile definition for newFile. */ | |
57 | #include "DiskFile.h" | |
58 | ||
59 | class SingletonIOStrategy : public DiskIOStrategy | |
60 | { | |
61 | ||
62 | public: | |
26ac0430 | 63 | SingletonIOStrategy(DiskIOStrategy *anIO) : io(anIO) {} |
b9ae18aa | 64 | |
337b9aa4 | 65 | bool shedLoad() override { return io->shedLoad(); } |
b9ae18aa | 66 | |
337b9aa4 | 67 | int load() override { return io->load(); } |
b9ae18aa | 68 | |
337b9aa4 | 69 | RefCount<DiskFile> newFile (char const *path) override {return io->newFile(path); } |
b9ae18aa | 70 | |
337b9aa4 | 71 | void sync() override { io->sync(); } |
b9ae18aa | 72 | |
337b9aa4 | 73 | bool unlinkdUseful() const override { return io->unlinkdUseful(); } |
c521ad17 | 74 | |
337b9aa4 | 75 | void unlinkFile(char const *path) override { io->unlinkFile(path); } |
b9ae18aa | 76 | |
337b9aa4 | 77 | int callback() override { return io->callback(); } |
b9ae18aa | 78 | |
337b9aa4 | 79 | void init() override { io->init(); } |
b9ae18aa | 80 | |
337b9aa4 | 81 | void statfs(StoreEntry & sentry) const override { io->statfs(sentry); } |
b9ae18aa | 82 | |
337b9aa4 | 83 | ConfigOption *getOptionTree() const override { return io->getOptionTree(); } |
b9ae18aa | 84 | |
85 | private: | |
86 | DiskIOStrategy *io; | |
87 | }; | |
88 | ||
ff9d9458 | 89 | #endif /* SQUID_SRC_DISKIO_DISKIOSTRATEGY_H */ |
f53969cc | 90 |