]> git.ipfire.org Git - thirdparty/squid.git/blame - src/DiskIO/DiskFile.h
Source Format Enforcement (#532)
[thirdparty/squid.git] / src / DiskIO / DiskFile.h
CommitLineData
59b2d47f 1/*
77b1029d 2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
59b2d47f 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.
59b2d47f 7 */
8
b9ae18aa 9#ifndef SQUID_DISKFILE_H
10#define SQUID_DISKFILE_H
59b2d47f 11
8bf217bd 12#include "base/RefCount.h"
6ebc477d 13#include "SquidTime.h"
59b2d47f 14
b9ae18aa 15class IORequestor;
16
17class ReadRequest;
18
19class WriteRequest;
20
21class DiskFile : public RefCountable
59b2d47f 22{
23
24public:
43ebbac3
AR
25
26 /// generally useful configuration options supported by some children
fc4dadeb
A
27 class Config
28 {
43ebbac3 29 public:
df881a0f 30 Config(): ioTimeout(0), ioRate(-1) {}
43ebbac3
AR
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
df881a0f
AR
34
35 /// shape I/O request stream to approach that many per second
36 int ioRate; // not enforced if negative, which is the default
43ebbac3
AR
37 };
38
b9ae18aa 39 typedef RefCount<DiskFile> Pointer;
63be0a78 40
43ebbac3 41 /// notes supported configuration options; kids must call this first
ced8def3 42 virtual void configure(const Config &) {}
43ebbac3 43
63be0a78 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;
b9ae18aa 46 virtual void read(ReadRequest *) = 0;
47 virtual void write(WriteRequest *) = 0;
63be0a78 48 virtual void close() = 0;
b9ae18aa 49 virtual bool canRead() const = 0;
50 virtual bool canWrite() const {return true;}
59b2d47f 51
63be0a78 52 /** During migration only */
b9ae18aa 53 virtual int getFD() const {return -1;}
54
55 virtual bool error() const = 0;
59b2d47f 56
63be0a78 57 /** Inform callers if there is IO in progress */
b9ae18aa 58 virtual bool ioInProgress() const = 0;
59};
59b2d47f 60
b9ae18aa 61#endif /* SQUID_DISKFILE_H */
f53969cc 62