]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/DiskIO/DiskFile.h
2 * Copyright (C) 1996-2014 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_DISKFILE_H
10 #define SQUID_DISKFILE_H
12 #include "base/RefCount.h"
21 class DiskFile
: public RefCountable
26 /// generally useful configuration options supported by some children
30 Config(): ioTimeout(0), ioRate(-1) {}
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
35 /// shape I/O request stream to approach that many per second
36 int ioRate
; // not enforced if negative, which is the default
39 typedef RefCount
<DiskFile
> Pointer
;
41 /// notes supported configuration options; kids must call this first
42 virtual void configure(const Config
&cfg
) {}
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;}
52 /** During migration only */
53 virtual int getFD() const {return -1;}
55 virtual bool error() const = 0;
57 /** Inform callers if there is IO in progress */
58 virtual bool ioInProgress() const = 0;
61 #endif /* SQUID_DISKFILE_H */