DiskThreadsDiskFile.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 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 /* DEBUG: section 79 Disk IO Routines */
10 
11 #ifndef SQUID_SRC_DISKIO_DISKTHREADS_DISKTHREADSDISKFILE_H
12 #define SQUID_SRC_DISKIO_DISKTHREADS_DISKTHREADSDISKFILE_H
13 
14 #include "cbdata.h"
15 #include "DiskIO/DiskFile.h"
16 #include "DiskThreads.h"
17 #include "typedefs.h" //for DWCB
18 
20 {
22 
23 public:
24  DiskThreadsDiskFile(char const *path);
25  ~DiskThreadsDiskFile() override;
26  void open(int flags, mode_t mode, RefCount<IORequestor> callback) override;
27  void create(int flags, mode_t mode, RefCount<IORequestor> callback) override;
28  void read(ReadRequest *) override;
29  void write(WriteRequest *) override;
30  void close() override;
31  bool error() const override;
32  int getFD() const override { return fd;}
33 
34  bool canRead() const override;
35  bool canWrite() const override;
36  bool ioInProgress() const override;
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 
54  int fd = -1;
55  bool errorOccured = false;
56  char const *path_ = nullptr;
57  size_t inProgressIOs = 0;
58  static AIOCB OpenDone;
59  void openDone(int fd, const char *buf, int aio_return, int aio_errno);
61  void doClose();
62 
63  void readDone(int fd, const char *buf, int len, int errflag, const RefCount<ReadRequest> &request);
64  void writeDone(int fd, int errflag, size_t len, RefCount<WriteRequest> request);
65 };
66 
67 #include "DiskIO/ReadRequest.h"
68 
69 template <class RT>
70 class IoResult
71 {
73 
74 public:
75  IoResult(RefCount<DiskThreadsDiskFile> aFile, RefCount<RT> aRequest) : file(aFile), request(aRequest) {}
76 
79 };
80 
81 template <class RT>
83 IOResult(RefCount<RT> aRequest, RefCount<DiskThreadsDiskFile> aFile) { return IoResult<RT>(aFile, aRequest);}
84 
85 #endif /* SQUID_SRC_DISKIO_DISKTHREADS_DISKTHREADSDISKFILE_H */
86 
RefCount< RT > request
CBDATA_CLASS(IoResult)
DiskThreadsDiskFile(char const *path)
CBDATA_CLASS(DiskThreadsDiskFile)
bool canWrite() const override
void DRCB(int, const char *buf, int size, int errflag, void *data)
Definition: typedefs.h:16
int getFD() const override
bool error() const override
bool canRead() const override
void open(int flags, mode_t mode, RefCount< IORequestor > callback) override
void read(ReadRequest *) override
void create(int flags, mode_t mode, RefCount< IORequestor > callback) override
IoResult< RT > IOResult(RefCount< RT > aRequest, RefCount< DiskThreadsDiskFile > aFile)
IoResult(RefCount< DiskThreadsDiskFile > aFile, RefCount< RT > aRequest)
void AIOCB(int fd, void *cbdata, const char *buf, int aio_return, int aio_errno)
Definition: DiskThreads.h:57
void writeDone(int fd, int errflag, size_t len, RefCount< WriteRequest > request)
RefCount< DiskThreadsDiskFile > file
bool ioInProgress() const override
unsigned short mode_t
Definition: types.h:129
void readDone(int fd, const char *buf, int len, int errflag, const RefCount< ReadRequest > &request)
void openDone(int fd, const char *buf, int aio_return, int aio_errno)
void DWCB(int, int, size_t, void *)
Definition: typedefs.h:18
RefCount< IORequestor > ioRequestor
void write(WriteRequest *) override

 

Introduction

Documentation

Support

Miscellaneous