]> git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskFile.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / DiskIO / DiskFile.h
1 /*
2 * Copyright (C) 1996-2017 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 #ifndef SQUID_DISKFILE_H
10 #define SQUID_DISKFILE_H
11
12 #include "base/RefCount.h"
13 #include "SquidTime.h"
14
15 class IORequestor;
16
17 class ReadRequest;
18
19 class WriteRequest;
20
21 class DiskFile : public RefCountable
22 {
23
24 public:
25
26 /// generally useful configuration options supported by some children
27 class Config
28 {
29 public:
30 Config(): ioTimeout(0), ioRate(-1) {}
31
32 /// canRead/Write should return false if expected I/O delay exceeds it
33 time_msec_t ioTimeout; // not enforced if zero, which is the default
34
35 /// shape I/O request stream to approach that many per second
36 int ioRate; // not enforced if negative, which is the default
37 };
38
39 typedef RefCount<DiskFile> Pointer;
40
41 /// notes supported configuration options; kids must call this first
42 virtual void configure(const Config &) {}
43
44 virtual void open(int flags, mode_t mode, RefCount<IORequestor> callback) = 0;
45 virtual void create(int flags, mode_t mode, RefCount<IORequestor> callback) = 0;
46 virtual void read(ReadRequest *) = 0;
47 virtual void write(WriteRequest *) = 0;
48 virtual void close() = 0;
49 virtual bool canRead() const = 0;
50 virtual bool canWrite() const {return true;}
51
52 /** During migration only */
53 virtual int getFD() const {return -1;}
54
55 virtual bool error() const = 0;
56
57 /** Inform callers if there is IO in progress */
58 virtual bool ioInProgress() const = 0;
59 };
60
61 #endif /* SQUID_DISKFILE_H */
62