]>
Commit | Line | Data |
---|---|---|
b9ae18aa | 1 | /* |
f70aedc4 | 2 | * Copyright (C) 1996-2021 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 | ||
bbc27441 AJ |
9 | /* DEBUG: section 79 Disk IO Routines */ |
10 | ||
b9ae18aa | 11 | #ifndef SQUID_DISKTHREADSDISKFILE_H |
12 | #define SQUID_DISKTHREADSDISKFILE_H | |
d35851f1 | 13 | |
aa839030 | 14 | #include "cbdata.h" |
b9ae18aa | 15 | #include "DiskIO/DiskFile.h" |
16 | #include "DiskThreads.h" | |
e1ba42a4 | 17 | #include "typedefs.h" //for DWCB |
b9ae18aa | 18 | |
19 | class DiskThreadsDiskFile : public DiskFile | |
20 | { | |
5c2f68b7 | 21 | CBDATA_CLASS(DiskThreadsDiskFile); |
b9ae18aa | 22 | |
23 | public: | |
43b6575c | 24 | DiskThreadsDiskFile(char const *path); |
b9ae18aa | 25 | ~DiskThreadsDiskFile(); |
63be0a78 | 26 | virtual void open(int flags, mode_t mode, RefCount<IORequestor> callback); |
27 | virtual void create(int flags, mode_t mode, RefCount<IORequestor> callback); | |
b9ae18aa | 28 | virtual void read(ReadRequest *); |
29 | virtual void write(WriteRequest *); | |
63be0a78 | 30 | virtual void close(); |
b9ae18aa | 31 | virtual bool error() const; |
32 | virtual int getFD() const { return fd;} | |
33 | ||
34 | virtual bool canRead() const; | |
35 | virtual bool canWrite() const; | |
63be0a78 | 36 | virtual bool ioInProgress() const; |
b9ae18aa | 37 | |
38 | private: | |
39 | #if ASYNC_READ | |
40 | ||
41 | static AIOCB ReadDone; | |
42 | #else | |
43 | ||
44 | static DRCB ReadDone; | |
45 | #endif | |
46 | #if ASYNC_WRITE | |
47 | ||
48 | static AIOCB WriteDone; | |
49 | #else | |
50 | ||
51 | static DWCB WriteDone; | |
52 | #endif | |
53 | ||
43b6575c AJ |
54 | int fd = -1; |
55 | bool errorOccured = false; | |
56 | char const *path_ = nullptr; | |
57 | size_t inProgressIOs = 0; | |
b9ae18aa | 58 | static AIOCB OpenDone; |
59 | void openDone(int fd, const char *buf, int aio_return, int aio_errno); | |
60 | RefCount<IORequestor> ioRequestor; | |
b9ae18aa | 61 | void doClose(); |
62 | ||
63be0a78 | 63 | void readDone(int fd, const char *buf, int len, int errflag, RefCount<ReadRequest> request); |
64 | void writeDone(int fd, int errflag, size_t len, RefCount<WriteRequest> request); | |
b9ae18aa | 65 | }; |
66 | ||
67 | #include "DiskIO/ReadRequest.h" | |
68 | ||
69 | template <class RT> | |
b9ae18aa | 70 | class IoResult |
71 | { | |
5c2f68b7 | 72 | CBDATA_CLASS(IoResult); |
b9ae18aa | 73 | |
74 | public: | |
26ac0430 | 75 | IoResult(RefCount<DiskThreadsDiskFile> aFile, RefCount<RT> aRequest) : file(aFile), request(aRequest) {} |
b9ae18aa | 76 | |
77 | RefCount<DiskThreadsDiskFile> file; | |
78 | RefCount<RT> request; | |
b9ae18aa | 79 | }; |
80 | ||
81 | template <class RT> | |
82 | IoResult<RT> | |
83 | IOResult(RefCount<RT> aRequest, RefCount<DiskThreadsDiskFile> aFile) { return IoResult<RT>(aFile, aRequest);} | |
84 | ||
85 | #endif /* SQUID_DISKTHREADSDISKFILE_H */ | |
f53969cc | 86 |