]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskIOStrategy.h
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_SRC_DISKIO_DISKIOSTRATEGY_H
10 #define SQUID_SRC_DISKIO_DISKIOSTRATEGY_H
12 #include "base/RefCount.h"
23 virtual ~DiskIOStrategy() {}
25 /** Can the IO Strategy handle more requests ? */
26 virtual bool shedLoad() = 0;
28 /** What is the current load? 999 = 99.9% */
29 virtual int load() = 0;
31 /** Return a handle for performing IO operations */
32 virtual RefCount
<DiskFile
> newFile(char const *path
) = 0;
34 /** flush all IO operations */
35 virtual void sync() {}
37 /** whether the IO Strategy can use unlinkd */
38 virtual bool unlinkdUseful() const = 0;
40 /** unlink a file by path */
41 virtual void unlinkFile(char const *) = 0;
43 /** perform any pending callbacks */
44 virtual int callback() { return 0; }
46 /** Init per-instance logic */
47 virtual void init() {}
49 /** cachemgr output on the IO instance stats */
50 virtual void statfs(StoreEntry
&) const {}
52 /** module specific options */
53 virtual ConfigOption
*getOptionTree() const {return nullptr;}
56 /* Because we need the DiskFile definition for newFile. */
59 class SingletonIOStrategy
: public DiskIOStrategy
63 SingletonIOStrategy(DiskIOStrategy
*anIO
) : io(anIO
) {}
65 bool shedLoad() override
{ return io
->shedLoad(); }
67 int load() override
{ return io
->load(); }
69 RefCount
<DiskFile
> newFile (char const *path
) override
{return io
->newFile(path
); }
71 void sync() override
{ io
->sync(); }
73 bool unlinkdUseful() const override
{ return io
->unlinkdUseful(); }
75 void unlinkFile(char const *path
) override
{ io
->unlinkFile(path
); }
77 int callback() override
{ return io
->callback(); }
79 void init() override
{ io
->init(); }
81 void statfs(StoreEntry
& sentry
) const override
{ io
->statfs(sentry
); }
83 ConfigOption
*getOptionTree() const override
{ return io
->getOptionTree(); }
89 #endif /* SQUID_SRC_DISKIO_DISKIOSTRATEGY_H */